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.
Instructions:
- Install
xdotool
(on Debian/Ubuntu/Mint) - Put the script somewhere and set it executable
- Use your desktop’s global hotkey support or a utility like
xbindkeys
to run the script whenever something likeCtrl+XF86AudioPlay
is pressed.
If you want it to do something other than play/pause, the simplest solution is probably to replace space
with "$@"
(including quotes) inside the script, save it under a name like smplayer_remote.sh
, and then set up associations like these:
XF86AudioPlay
→smplayer_remote.sh space
XF86AudioRewind
→smplayer_remote.sh Left
XF86AudioForward
→smplayer_remote.sh Right
(You can find the keysym names using the xev
tool (on Debian/Ubuntu/Mint) and man xdotool
will tell you how to specify modifier keys like Ctrl
and Alt
)
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.
Quick Hack: Global Hotkeys for SMPlayer by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Please explain the detailed on YouTube
I need this road very much but I do not understand the steps
I ask you to make an explanation I need you badly 🙁
Sorry, but I don’t do video tutorials and, even if I did, I haven’t logged into YouTube since Google started requiring that I create a Google Profile (ie. tell them more about me) to post comments.
However, if you can explain where you’re having trouble, I’d be happy to improve the instructions.
Thanks! Just what I needed. I used VLC before because there global hotkkeys work but now I’m using SMPlayer.
Thanks, bye!