NalleRooth.com

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.

  1. Open System Settings (Press Alt + Space, type system-settings [Enter]).
  2. Click Shortcuts System Settings
  3. Select Custom shortcuts in the left menu Custom shortcuts
  4. Press Edit > New > Global shortcut > D-Bus Command. Add new global, dbus command
  5. Click the tab Trigger
  6. 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 Shortcut button
  7. Click the Action tab. This is where we’ll add some magic.
  8. Enter the following into the form: Play/Pause DBus commands
    1. Remote application: org.mpris.MediaPlayer2.spotify
    2. Remote object: /org/mpris/MediaPlayer2
    3. Function: org.mpris.MediaPlayer2.Player.PlayPause
    4. (Leave the Arguments field blank).
  9. Open Spotify, if it’s not already running.
  10. Press the call button. Spotify should play/pause the current track each time the button is pressed. Press the Call button to test the setup
  11. Double click the New Action item in the list to the left, and enter something more informative, like Spotify Play Name the action you’ve created
  12. Press the Apply button at the bottom of the window to store your settings. Save your settings by clicking Apply

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!

Posted:
Tags: spotify kde linux
comments powered by Disqus