Guest User

Untitled

a guest
Dec 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. moveX=$1
  4. moveY=$2
  5. sizeX=$3
  6. sizeY=$4
  7.  
  8. if [ -z "$moveX" ] || [ -z "$moveY" ] || [ -z "$sizeX" ] || [ -z "$sizeY" ]; then
  9. echo "USAGE: ./wmctrl.sh moveX moveY sizeX sizeY"
  10. 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:"
  11. echo -e " ./wmctrl.sh -5 -5 5 5n"
  12. echo " Note: you can use '-' to leave any parameter unchanged."
  13. else
  14. set -- $(xwininfo -id $(xdotool getactivewindow) | awk -F ': +' '/ (Absolute upper-left X|Absolute upper-left Y|Width|Height):/ { print $2 }')
  15.  
  16. winX=$1; winY=$2; width=$3; height=$4
  17.  
  18. if [ $moveX == "-" ]; then nx=-1; else nx=$((winX+moveX)); fi
  19. if [ $moveY == "-" ]; then ny=-1; else ny=$((winY+moveY)); fi
  20. if [ $sizeX == "-" ]; then nw=-1; else nw=$((sizeX+width)); fi
  21. if [ $sizeY == "-" ]; then nh=-1; else nh=$((sizeY+height)); fi
  22.  
  23. echo "( <$moveX, $moveY> <$sizeX, $sizeY> + <$winX, $winY> <$width, $height> ) => <$nx, $ny> <$nw, $nh>"
  24.  
  25. wmctrl -r :ACTIVE: -e "0,$nx,$ny,$nw,$nh"
  26. fi
  27.  
  28. 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
  29. 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
  30. current geometry value should not be modified
Add Comment
Please, Sign In to add comment