#!/bin/zsh # windowbounce - shift current X11 window around # originally by http://xmw.de/dotfiles/scripts/windowbounce BORDER_RIGHT=252 BORDER_TOP=12 BORDER_BOT=14 if ! xdotool getdisplaygeometry 2>/dev/null ; then echo "you need xdootool version 2.20110530.1 or newer to use getdisplaygeometry" 1>&2 exit -1 fi eval `xdotool getdisplaygeometry --shell` (( SW=WIDTH-2 )) (( SH=HEIGHT-2 )) eval `xdotool getactivewindow getwindowgeometry --shell` # weird xdotool bug? #(( X2=X=X/2 )) #(( Y2=Y=Y/2 )) case $1 in h) (( X=1, WIDTH = (X+WIDTH >= SW ? SW-X : WIDTH) ));; j) (( Y=(Y+HEIGHT == SH ? SH-HEIGHT-BORDER_BOT : SH-HEIGHT) )) (( Y < 1 && (HEIGHT+=Y, Y=1) ));; k) (( Y = (Y == 1 ? BORDER_TOP : 1) )) (( Y+HEIGHT >= SH && (HEIGHT = SH-Y-1) ));; l) (( X=(X+WIDTH == SW ? SW-WIDTH-BORDER_RIGHT : SW-WIDTH) )) (( X < 1 && (WIDTH+=X, X=1) ));; esac xdotool getactivewindow \ windowmove $X $Y \ windowsize $WIDTH $HEIGHT \ mousemove_relative -- $((X-X2)) $((Y-Y2))