Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Quick hack to toggle play/pause in SMPlayer externally for global hotkey binding
OLD_WID="$(xdotool getactivewindow)"
until [ -n "$WID" ]; do
WID="$(xdotool search --name '[-][ ]SMPlayer' 2>/dev/null)"
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 #
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
You can’t perform that action at this time.