Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- moveX=$1
- moveY=$2
- sizeX=$3
- sizeY=$4
- if [ -z "$moveX" ] || [ -z "$moveY" ] || [ -z "$sizeX" ] || [ -z "$sizeY" ]; then
- echo "USAGE: ./wmctrl.sh moveX moveY sizeX sizeY"
- echo " eg, to resize by <5,5> and move by <-5,-5>, so it looks like it grew <5,5> in the top left, use:"
- echo -e " ./wmctrl.sh -5 -5 5 5n"
- echo " Note: you can use '-' to leave any parameter unchanged."
- else
- set -- $(xwininfo -id $(xdotool getactivewindow) | awk -F ': +' '/ (Absolute upper-left X|Absolute upper-left Y|Width|Height):/ { print $2 }')
- winX=$1; winY=$2; width=$3; height=$4
- if [ $moveX == "-" ]; then nx=-1; else nx=$((winX+moveX)); fi
- if [ $moveY == "-" ]; then ny=-1; else ny=$((winY+moveY)); fi
- if [ $sizeX == "-" ]; then nw=-1; else nw=$((sizeX+width)); fi
- if [ $sizeY == "-" ]; then nh=-1; else nh=$((sizeY+height)); fi
- echo "( <$moveX, $moveY> <$sizeX, $sizeY> + <$winX, $winY> <$width, $height> ) => <$nx, $ny> <$nw, $nh>"
- wmctrl -r :ACTIVE: -e "0,$nx,$ny,$nw,$nh"
- fi
- The four remaining values are a standard geometry specification: x,y is the position of the top left corner of the window, and w,h
- is the width and height of the window, with the exception that the value of -1 in any position is interpreted to mean that the
- current geometry value should not be modified
Add Comment
Please, Sign In to add comment