Created
April 23, 2016 14:05
-
-
Save ssokolow/a5d242d6104a37cfd8d2067b322eb157 to your computer and use it in GitHub Desktop.
Quick hack to toggle play/pause in SMPlayer externally for global hotkey binding
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 | |
OLD_WID="$(xdotool getactivewindow)" | |
WID="" | |
until [ -n "$WID" ]; do | |
WID="$(xdotool search --name '[-][ ]SMPlayer' 2>/dev/null)" | |
done | |
echo "$WID" | |
# This seems to be race-y and this is the best mitigation I could find | |
# (--sync tends to hang xdotool when it would work, windowfocus is unreliable) | |
xdotool windowactivate "$WID" | |
sleep 0.1 # http://serverfault.com/a/469249 | |
xdotool key --window "$WID" space # EDIT THIS LINE TO CHANGE ACTION | |
xdotool windowactivate "$OLD_WID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment