Skip to content

Instantly share code, notes, and snippets.

@ColinHarrington
Created November 16, 2012 18:07
Show Gist options
  • Save ColinHarrington/4089500 to your computer and use it in GitHub Desktop.
Save ColinHarrington/4089500 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get active window attributes
ACTIVE_WINDOW=$(xdotool getactivewindow)
ACTIVE_GEOMETRY=$(xdotool getwindowgeometry $(xdotool getactivewindow))
ACTIVE_WIDTH=$(echo $ACTIVE_GEOMETRY | cut -d ' ' -f8 | cut -d 'x' -f1)
ACTIVE_HEIGHT=$(echo $ACTIVE_GEOMETRY | cut -d ' ' -f8 | cut -d 'x' -f2)
# Get screen attributes
WIDTH=`xdotool getdisplaygeometry | cut -d' ' -f1`
HEIGHT=`xdotool getdisplaygeometry | cut -d' ' -f2`
HALF_WIDTH=`expr $WIDTH / 2`
HALF_HEIGHT=`expr $HEIGHT / 2`
THIRD_WIDTH=`expr $WIDTH / 3`
TWO_THIRD_WIDTH=`expr $THIRD_WIDTH \* 2`
echo $WIDTH
echo $THIRD_WIDTH
echo $TWO_THIRD_WIDTH
if [ $ACTIVE_WIDTH -eq $HALF_WIDTH ]
then
xdotool windowsize $ACTIVE_WINDOW $THIRD_WIDTH $HEIGHT
xdotool windowmove $ACTIVE_WINDOW $TWO_THIRD_WIDTH 0
elif [ $ACTIVE_WIDTH -eq $THIRD_WIDTH ]
then
xdotool windowsize $ACTIVE_WINDOW $TWO_THIRD_WIDTH $HEIGHT
xdotool windowmove $ACTIVE_WINDOW $THIRD_WIDTH 0
else
xdotool windowsize $ACTIVE_WINDOW $HALF_WIDTH $HEIGHT
xdotool windowmove $ACTIVE_WINDOW $HALF_WIDTH 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment