Last active
February 21, 2018 15:42
-
-
Save sleekweasel/bc7fc34ad33c9dc7126ca10ed2c9ffc4 to your computer and use it in GitHub Desktop.
Tile X11 windows from the command-line with xdotool
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
tile_emulators() { | |
DGEO=$(xdotool getdisplaygeometry) | |
index=0 | |
for p in $( xdotool search 'enymotion' getwindowpid %@|sort |uniq ) ; do | |
GEOM=$(perl -le " | |
%A=(tot=>$EMULATORS, ix=>$index, dx=>${DGEO% *}, dy=>${DGEO#* });"' | |
$sq = int(sqrt($A{tot})); $sq++ if sqrt($A{tot}) > $sq; | |
$sx=$A{dx}/$sq; $sy=$A{dy}/$sq; | |
print "windowsize $sx $sy windowmove ",($A{ix} % $sq) * $sx," ",int($A{ix} / $sq) * $sy' | |
); | |
eval "xdotool search --all --pid $p --onlyvisible --class 'enymotion' $GEOM"; | |
index=$[ index + 1 ]; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Illegal division by zero =/ Too many windows?
Update: I think my $EMULATORS env var is empty.