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