2021-11-02 00:17:59 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -ueo pipefail
|
|
|
|
|
2021-11-02 21:39:47 +00:00
|
|
|
# assuming that all displays are the same width
|
2021-11-02 00:17:59 +00:00
|
|
|
displayWidth=$(xdotool getdisplaygeometry | cut -d' ' -f1)
|
|
|
|
|
|
|
|
xPos=$(xdotool getactivewindow getwindowgeometry | grep Position: | cut -d: -f2 | cut -d, -f1 | tr -d ' ')
|
2021-11-02 21:39:47 +00:00
|
|
|
|
|
|
|
# don't ask questions about magic numbers
|
2021-11-02 00:17:59 +00:00
|
|
|
if [[ "${xPos}" -ge "${displayWidth}" ]]; then
|
2021-11-02 21:39:47 +00:00
|
|
|
newXPos="-$((displayWidth + 3))"
|
2021-11-02 00:17:59 +00:00
|
|
|
else
|
2021-11-02 21:39:47 +00:00
|
|
|
newXPos="$((displayWidth - 5))"
|
2021-11-02 00:17:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# i don't know why the y value is offset, but it is what it is
|
|
|
|
xdotool getactivewindow windowmove --relative -- "${newXPos}" -50
|