Skip to content

Instantly share code, notes, and snippets.

@Veedrac
Last active August 29, 2015 13:56
Show Gist options
  • Save Veedrac/9172455 to your computer and use it in GitHub Desktop.
Save Veedrac/9172455 to your computer and use it in GitHub Desktop.
# 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