Created
May 21, 2018 16:39
-
-
Save taikedz/e94991562db9f1f2e5fcafe93f236473 to your computer and use it in GitHub Desktop.
Script to maximize and minimize an X window from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maxi() { | |
if [[ "$1" =~ ^0x[0-9a-f]+$ ]]; then | |
wmctrl -i -r "$1" -b toggle,maximized_vert,maximized_horz | |
# the window will be in the foreground, but not given focus | |
else | |
echo "No valid window supplied: got [$1]" | |
fi | |
} | |
die() { | |
echo "$*" | |
exit 1 | |
} | |
which wmctrl >/dev/null 2>&1 || die "Please install 'wmctrl'" | |
if [[ -z "$*" ]]; then | |
wmctrl -l | |
echo "--- Provide the ID or part fo the name of a window ---" | |
elif [[ "$1" =~ ^0x ]]; then | |
maxi "$1" | |
else | |
maxi "$(wmctrl -l | grep "$1" | grep -oP '^0x\S+')" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment