Skip to content

Instantly share code, notes, and snippets.

@debuti
Last active May 5, 2020 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debuti/a6f851142c467a976574e6a08ae26b20 to your computer and use it in GitHub Desktop.
Save debuti/a6f851142c467a976574e6a08ae26b20 to your computer and use it in GitHub Desktop.
Playing around with window manager in linux

Get screen dimensions

SWIDTH=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f1 -dx)
SHEIGHT=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f2 -dx)

Current desktop

wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" "

Current desktop windows

wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")"

All t32 instances of the current desktop

wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")" | grep t32marm

Move and resize window

wmctrl -ir $WID -e 0,X,Y,W,H

Move all windows in a horizontal tile

TITLE=Pluma;
WIDS=( $(wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")" | grep $TITLE | cut -f1 -d" ") )
COUNT=$(echo "${#WIDS[@]}")
WW=$(( $SWIDTH / $COUNT )) 
for i in "${!WIDS[@]}"; do
  wmctrl -ir ${WIDS[$i]} -e 0,$(( $WW * $i )),0,$WW,$SHEIGHT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment