Created
February 24, 2016 03:59
-
-
Save aikar/f762a79e86653406c448 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
#!/bin/bash | |
function xdt { | |
xdotool "$@" | |
} | |
function getobs { | |
xdotool search --onlyvisible --class obs | head -n 1 | |
} | |
export xdt | |
function getcurrentx { | |
xdotool getmouselocation | awk '{print $1}' | cut -c3- | |
} | |
function dokey { | |
wid=$(xdt getactivewindow) | |
obs=$(getobs) | |
if [ -z "$obs" ]; then | |
return 1 | |
fi | |
xdt windowfocus $obs | |
xdt key "$@" | |
xdt windowfocus $wid | |
} | |
export getcurrentx | |
function startswitch { | |
trap "" HUP | |
current="" | |
while : ; do | |
x="$(getcurrentx)" | |
if [[ "$x" -gt 3840 ]]; then | |
if [ "$current" != "2" ]; then | |
dokey "ctrl+alt+bracketright" && current="2" | |
fi | |
else | |
if [ "$current" != "1" ]; then | |
dokey "ctrl+alt+bracketleft" && current="1" | |
fi | |
fi | |
sleep .2 | |
done | |
} | |
export -f startswitch | |
startswitch & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment