Created
November 16, 2017 04:09
-
-
Save Fordi/e3aa57b91cfef7561e252c2c5b801d0f to your computer and use it in GitHub Desktop.
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
#!/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 |
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
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).