I have a family member who has grown used to pausing Audacious Media Player with a quick press on their
XF86AudioPlay key, but half of what they listen to is video files, so I wrote a quick shell script to work around SMPlayer‘s lack of global hotkey support.
- Put the script somewhere and set it executable
- Use your desktop’s global hotkey support or a utility like
xbindkeysto run the script whenever something like
If you want it to do something other than play/pause, the simplest solution is probably to replace
"$@" (including quotes) inside the script, save it under a name like
smplayer_remote.sh, and then set up associations like these:
I initially tried to make it behave exactly like a real global hotkey would, but
xdotool seems to have an unavoidable race condition and no way to force a 100ms delay after using the
windowfocus command… so, instead, this will momentarily switch window focus, then restore whatever you were working on before.
It should be possible to do it properly if I were willing to either patch
xdotool or drop down and write against the bare X11 APIs, but I just don’t have the time for either and this is Good Enough™ for the intended use case.