I’ve fallen in love with Music Player Daemon, also commonly known as MPD. It’s client-server architecture makes it easy to use multiple controllers at the same time.
For example, while sitting at the computer you could be using ncmpcpp CLI-client, and while doing something away from keyboard you could use e.g. MPDroid available on Google Play . It really makes using computer much more enjoyable.
Anyway, one thing didn’t allow me to enjoy my MPD experience. I spend a lot of time with Netbeans and Eclipse IDEs, and one thing they taught me is that keyboard hotkeys can save you a lot of time. It would be much better if you could change current track with single keystroke combination the same way some other music players allow , wouldn’t it?
Fortunately, some clever guys thought about it and came up with MPRIS, standard providing unified D-Bus interface for controlling media players. That and Its implementation for MPD – MpDris2 allow us to communicate with MPD using simple commands. Below I’m describing how to get keyboard shortcut keys working on KDE.
- Grab MpDris2 for your Linux distribution, don’t use deprecated first version of package which still is shipped with some distributions(e.g. Ubuntu/Mint).
- Once you’ve completed previous step go to KDE System Settings -> Shortcuts and Gestures. In the Custom Shortcuts group create new D-Bus Command by clicking RMB and selecting New -> Global Shortcut -> D-Bus Command.
- In the Trigger tab you can set your shortcut for given action.
- In new entry’s Action tab you should fill fields in the following way:
- In “Remote application:” there always be “org.mpris.MediaPlayer2.mpd”
- In “Remote object:” “/org/mpris/MediaPlayer2″
- In function you define which function you want to invoke (Play/Stop/Next etc.), for example Play function is defined as “org.mpris.MediaPlayer2.Player.Play”. More information about available functions you can get on MPRIS documentation page or by using “Launch D-Bus Browser” button. Remember not to include whitespaces in your entries or it won’t work at all without giving you any hint why
If you don’t feel like filling all those fields, go ahead and Import the basic mapping I prepared for myself: mpd-mpris-keys.
As a bonus, with MpDris2 you get nice integration with KDE notifications bar showing currently played song:
Ok, seems like I finally managed to publish my first, and hopefully not last, post