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
@VictorAseo
Copy link

where can I put that file?

@Fordi
Copy link
Author

Fordi commented Feb 26, 2021

where can I put that file?

Wherever you stick stuff you keep in your user's $PATH - for me that's ~/.bin, but whatever you use. You'd then assign it a GUI keyboard shortcut, but run it as a not-a-console program (because you don't want a console window to show up).

@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