Skip to content

Instantly share code, notes, and snippets.

@taikedz
Created May 21, 2018 16:39
Show Gist options
  • Save taikedz/e94991562db9f1f2e5fcafe93f236473 to your computer and use it in GitHub Desktop.
Save taikedz/e94991562db9f1f2e5fcafe93f236473 to your computer and use it in GitHub Desktop.
Script to maximize and minimize an X window from the command line
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