Skip to content

Instantly share code, notes, and snippets.

@mkoura
Last active September 3, 2016 12:23
Show Gist options
  • Save mkoura/c055133b841f0f0ebd527b4335c96c08 to your computer and use it in GitHub Desktop.
Save mkoura/c055133b841f0f0ebd527b4335c96c08 to your computer and use it in GitHub Desktop.
no titlebar for maximized windows - map this script to Alt+F10 (and Super+Up in Gnome 3) and use it for window maximization
#!/bin/sh
missing_command=0
hash xprop 2>/dev/null || { echo "${0##*/}: please install xprop" >&2; missing_command=1; }
hash wmctrl 2>/dev/null || { echo "${0##*/}: please install wmctrl" >&2; missing_command=1; }
[ "$missing_command" -eq 1 ] && exit 1
case "$1" in
res*)
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
exit 0
;;
max*)
todo=max
;;
*)
todo=toggle
;;
esac
window_props() {
cardinal=_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED
retval=0
# get id of active window
xprop_out="$(xprop -root _NET_ACTIVE_WINDOW)"
[ -n "$xprop_out" ] && window="${xprop_out#*# }"
[ -z "$window" ] && return "$retval"
# check if the cardinal is set
if [ "$(xprop -id "$window" "$cardinal")" != "${cardinal}(CARDINAL) = 1" ]; then
# cardinal is not set: set the cardinal
# and indicate that the window needs to be (re-)maximized
xprop -id "$window" -f "$cardinal" 32c -set "$cardinal" 0x1 && retval=1
fi
return "$retval"
}
window_props
[ "$?" -eq 1 ] && todo=remax
case "$todo" in
'remax')
# re-maximize the window to take effect
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
;;
'max')
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
;;
'toggle')
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment