Created
February 10, 2015 09:49
-
-
Save cl4u2/29ad8db3f2711e756fd5 to your computer and use it in GitHub Desktop.
jail the mouse to a specific rectangle. Based on xdotool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SLEEPTIME=0.2 | |
# JAIL PARAMETERS | |
MAXX=1024 | |
MAXY=768 | |
BOUNDSCREEN=0 | |
while true; do | |
eval $(xdotool getmouselocation --shell 2>/dev/null) | |
echo $X, $Y, $SCREEN | |
NEWX=$X | |
NEWY=$Y | |
JAIL=0 | |
if (($X > $MAXX)); then NEWX=$MAXX; JAIL=1; fi | |
if (($Y > $MAXY)); then NEWY=$MAXY; JAIL=1; fi | |
if (($SCREEN != $BOUNDSCREEN)); then JAIL=1; fi | |
if (($JAIL == 1)); then | |
xdotool mousemove --screen $BOUNDSCREEN $NEWX $NEWY | |
fi | |
sleep $SLEEPTIME | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment