doti3/i3_switch_monitor.sh

26 lines
558 B
Bash
Executable File

#!/bin/sh
MONITOR1_WIDTH=$1
MONITOR2_WIDTH=$2
MONITOR3_WIDTH=$3
getMouseX() {
xdotool getmouselocation 2>/dev/null | awk '{ print $1 }' | cut -d: -f2
}
getMouveNextX() {
if [ $(getMouseX) -lt $MONITOR1_WIDTH ]; then
echo $(($MONITOR1_WIDTH + $MONITOR2_WIDTH / 2 - 10))
elif [ -n "$MONITOR3_WIDTH" -a $(getMouseX) -lt $(($MONITOR1_WIDTH + $MONITOR2_WIDTH)) ]; then
echo $(($MONITOR1_WIDTH + $MONITOR2_WIDTH + $MONITOR3_WIDTH / 2 - 10))
else
echo $((MONITOR1_WIDTH / 2 - 10))
fi
}
moveTo() {
xdotool mousemove $1 540
}
moveTo $(getMouveNextX)