Skip to content

Instantly share code, notes, and snippets.

@Fordi
Created November 16, 2017 04:09
Show Gist options
  • Save Fordi/e3aa57b91cfef7561e252c2c5b801d0f to your computer and use it in GitHub Desktop.
Save Fordi/e3aa57b91cfef7561e252c2c5b801d0f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Will maximize the current window to a new desktop, or, if the window is not
# Use your window manager's keybindings to attach this script to the key combination of your choice
# Requires the following packages in Ubuntu:
# xdotool x11-utils wmctrl
function goFull() {
echo $1
DESKTOP=`wmctrl -d | cut -d \ -f 1 | tail -1`
wmctrl -ir $1 -b add,fullscreen
wmctrl -ir $1 -t $DESKTOP
wmctrl -s $DESKTOP
}
function unFull() {
wmctrl -ir $1 -b remove,fullscreen
wmctrl -ir $1 -t 0
wmctrl -s 0
}
WINDOW_ID="$(printf 0x%08x $(xdotool getactivewindow))"
echo $WINDOW_ID
IS_FULL="$(xprop -id $WINDOW_ID | grep '_NET_WM_STATE(ATOM)' | grep '_NET_WM_STATE_FULLSCREEN')"
echo $IS_FULL
if [[ -n "$IS_FULL" ]]; then
unFull $WINDOW_ID
else
goFull $WINDOW_ID
fi
@Fordi
Copy link
Author

Fordi commented Feb 26, 2021

Also, I wrote this for classic X11, two computers ago - I don't know that it works with modern Wayland stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment