Created
September 7, 2016 13:24
-
-
Save ryot4/84ff632f7faf59ece66741c355248b88 to your computer and use it in GitHub Desktop.
Move the active X11 window in the specified direction
This file contains hidden or 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/sh | |
# dependency: xdotool and wmctrl | |
eval $(xdotool getactivewindow getwindowgeometry --shell) | |
DESKTOP=$(wmctrl -d | awk '{ print $4 }' | tr x ' ') | |
DWIDTH=$(echo $DESKTOP | cut -d ' ' -f 1) | |
DHEIGHT=$(echo $DESKTOP | cut -d ' ' -f 2) | |
case $1 in | |
left) | |
X=0 | |
# West | |
GRAVITY=4 | |
;; | |
right) | |
X=$((DWIDTH - WIDTH)) | |
# East | |
GRAVITY=6 | |
;; | |
up) | |
Y=0 | |
# North | |
GRAVITY=2 | |
;; | |
down) | |
Y=$((DHEIGHT - HEIGHT)) | |
# South | |
GRAVITY=8 | |
;; | |
*) | |
echo 'unknown direction' | |
exit 1 | |
;; | |
esac | |
wmctrl -r :ACTIVE: -e "$GRAVITY,$X,$Y,-1,-1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment