Skip to content

Instantly share code, notes, and snippets.

@aikar
Created February 24, 2016 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aikar/f762a79e86653406c448 to your computer and use it in GitHub Desktop.
Save aikar/f762a79e86653406c448 to your computer and use it in GitHub Desktop.
#!/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