Skip to content

Instantly share code, notes, and snippets.

@sleekweasel
Last active February 21, 2018 15:42
Show Gist options
  • Save sleekweasel/bc7fc34ad33c9dc7126ca10ed2c9ffc4 to your computer and use it in GitHub Desktop.
Save sleekweasel/bc7fc34ad33c9dc7126ca10ed2c9ffc4 to your computer and use it in GitHub Desktop.
Tile X11 windows from the command-line with xdotool
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
}
@ageis
Copy link

ageis commented Feb 21, 2018

Illegal division by zero =/ Too many windows?

        %A=(tot=>, ix=>0, dx=>1920, dy=>1080);
        $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'
Illegal division by zero at -e line 4.
+ GEOM=

Update: I think my $EMULATORS env var is empty.

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