You love music, and what Spotify does for you, you say? As do I!
I also happen to enjoy playing around with Linux, and if you happened upon this blog, chances are so do you.
The two work fairly well together, but it also lacks a few things here and there; one of those things are global Media Hotkeys!
The solution is fairly simple in KDE after Spotify included D-bus support, and that's what I'll be showing you.
A python script exists that enables song notification and global hotkeys, but I don't know if it works
with KDE, and the last version closes unexpectedly for me, so it might not even be working at all.
First, go to:
System Settings > Shortcuts and Gestures
Under "Custom Shortcuts" we'll be adding four entries, this is done by right-clicking the white field, and in the menu selecting:
New > Global Shortcut > D-Bus Command
Entry #1 "Spotify Play":
Having named and selected the new shortcut, you will have three tabs on the right:
[Comment] [Trigger] [Action]
Fairly straight forward right? The comment is just that, a comment; the trigger is what key or key-combo you will use to trigger the shortcut; "Action" is what the shortcut will do.
Head to the "Action" tab, here you will see four text fields:
Remote Application, Remote Object, Function, and Arguments.
We'll be using the first three fields.
Remote Applications: org.mpris.MediaPlayer2.spotify
Remote Object: /org/mpris/MediaPlayer2
Function: org.mpris.MediaPlayer2.Player.PlayPause
Now, head to the "Trigger" tab, here you will bind your preferred key.
Simply click once on the only button there, and then they key or key-combination you wish to bind it to.
Hit "Apply" in the lower right corner.
You have now successfully bound your Media Key "Play" as a global shortcut for spotify.
Entry #2 "Spotify Stop":
The only difference here is what function the shortcut has, and which key you bind.
Function: org.mpris.MediaPlayer2.Player.Stop
Entry #3 "Spotify Next":
Function: org.mpris.MediaPlayer2.Player.Next
Entry #4 "Spotify Previous":
Function: org.mpris.MediaPlayer2.Player.Previous