Skip to content

Instantly share code, notes, and snippets.

@noisy
Last active May 14, 2016 05:56
Show Gist options
  • Save noisy/43ac74c390830acf20aae4ab7a4be8dc to your computer and use it in GitHub Desktop.
Save noisy/43ac74c390830acf20aae4ab7a4be8dc to your computer and use it in GitHub Desktop.
#!/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