Configuring Spotify Media keys in KDE 5.4
I think that KDE is an amazing desktop environment to work in, and since I often want to listen to music while I work, I want my media keys to work with Spotify. This is however often not the case after a fresh desktop install. But since this is KDE we’re talking about - we can configure it to do exacly what we want, in a few simple steps. Let’s get started.
- Open System Settings (Press
Alt + Space, type system-settings [Enter]
). - Click Shortcuts
- Select Custom shortcuts in the left menu
- Press Edit > New > Global shortcut > D-Bus Command.
- Click the tab Trigger
- Click the Shortcut button, followed by pressing the Play/Pause button on your keyboard. (If you get a warning about the key already being assigned to some other action - just confirm that it should be assigned to this command instead.)
- Click the Action tab. This is where we’ll add some magic.
- Enter the following into the form:
- Remote application:
org.mpris.MediaPlayer2.spotify
- Remote object:
/org/mpris/MediaPlayer2
- Function:
org.mpris.MediaPlayer2.Player.PlayPause
- (Leave the Arguments field blank).
- Remote application:
- Open Spotify, if it’s not already running.
- Press the call button. Spotify should play/pause the current track each time the button is pressed.
- Double click the New Action item in the list to the left, and enter something more informative, like Spotify Play
- Press the Apply button at the bottom of the window to store your settings.
Next/Prev track
Using the technique above, you can also map Media Next/Previous keys to Spotify. The only difference is which key you press and that in step 8.3, you enter the following:
Next track: org.mpris.MediaPlayer2.Player.Next
Previous track: org.mpris.MediaPlayer2.Player.Previous
Your media keys should now send messages to Spotify, even if Spotify is somewhere in the background.
Enjoy!