Last active
August 29, 2015 13:56
-
-
Save Veedrac/9172455 to your computer and use it in GitHub Desktop.
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
# Customise this to allow things to have the mouse but not the keyboard. | |
# It's just regex and matches this window name. | |
ALLOWED='^(i3(bar\ .*)?|)$' | |
REPEAT=false | |
while true; do | |
eval $(xdotool getmouselocation --shell) | |
# Uncomment for helping data to use when editing $ALLOWED. | |
# echo "-----------" | |
# echo "Mouse Window: " $WINDOW | |
# echo "Mouse Window Name:" "$(xdotool getwindowname $WINDOW)" | |
# echo "Active Window: " "$(xdotool getactivewindow)" | |
# echo | |
if [[ | |
$WINDOW -ne 0 && | |
! ( "$(xdotool getwindowname $WINDOW)" =~ $ALLOWED ) && | |
$WINDOW -ne $(xdotool getactivewindow) | |
]]; then | |
# Repeat to prevent timing errors due to changes between calls to xdotool | |
if $REPEAT; then xdotool getactivewindow mousemove -w %1 --polar 0 0; fi | |
REPEAT=true | |
else | |
sleep 0.1 | |
REPEAT=false | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment