./push-window.sh <top|right|bottom|left>...
for example
$ ./push-window top right
$ ./push-window left| #!/usr/bin/env bash | |
| raw=$(swaymsg -t get_tree) | |
| read wx wy ww wh < <(jq -r '.. | |
| | (.floating_nodes? // empty)[] | |
| | select(.focused==true) | |
| | .rect | |
| | "\(.x) \(.y) \(.width) \(.height)"' <<< $raw) | |
| read wsx wsy wsw wsh < <(jq -r '.. | |
| | (.nodes? // empty)[] | |
| | select(.type=="workspace") | |
| | select(.. | .focused?==true) | |
| | .rect | |
| | "\(.x) \(.y) \(.width) \(.height)"' <<< $raw) | |
| if [[ -z $wx ]]; then | |
| echo "Focused window is not floating" | |
| exit 1 | |
| fi | |
| x=$(($wx-$wsx)) | |
| y=$(($wy-$wsy)) | |
| while (($#)); do | |
| case $1 in | |
| left) x=0;; | |
| top) y=0;; | |
| right) x=$(($wsw-$ww));; | |
| bottom) y=$(($wsh-$wh));; | |
| *) echo "Unrecognized direction" >&2; exit 1;; | |
| esac | |
| shift | |
| done | |
| swaymsg move position $x $y |