Last active
May 14, 2016 05:56
-
-
Save noisy/43ac74c390830acf20aae4ab7a4be8dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# requirements: sudo apt-get install xautomation xdotool | |
cleanup () | |
{ | |
sleep 1 | |
xte 'keyup Control_L' 'keyup Alt_L' 'keyup Shift_L' | |
sleep 1 | |
xte 'keyup Control_L' 'keyup Super_L' 'keyup Alt_L' | |
exit 0 | |
} | |
trap cleanup SIGINT SIGTERM | |
FOCUS_ON=1 | |
while true | |
do | |
eval $(xdotool getmouselocation --shell) | |
if [ $X -lt 1920 ]; then | |
if [ $FOCUS_ON -eq 2 ]; then | |
echo "Switching to scene 1 ..." | |
xte 'keydown Control_L' 'keydown Super_L' 'keydown Alt_L' | |
sleep 1 | |
xte 'keyup Control_L' 'keyup Super_L' 'keyup Alt_L' | |
FOCUS_ON=1 | |
fi | |
else | |
if [ $FOCUS_ON -eq 1 ]; then | |
echo "Switching to scene 2 ..." | |
xte 'keydown Control_L' 'keydown Alt_L' 'keydown Shift_L' | |
sleep 1 | |
xte 'keyup Control_L' 'keyup Alt_L' 'keyup Shift_L' | |
FOCUS_ON=2 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment