How to toggle playing/pausing of Spotify using the Pause key in Ubuntu
According to Mabishu:
After a lot of requests from Linux users, Spotify developers have integrated D-Bus support in version 0.4.8.282. So, what this means is simply and awesome! Now Linux developers could use this programmatic interface to interact with Spotify from other apps.
In other words, now is quite simple to send «play», «pause», «move next/previous song» events to Spotify and with this get Spotify fully integrate into our desktop.
To toggle playing and pausing from the terminal, run:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
To hook it to the Pause/Break keyboard key:
- Select System -> Preferences -> Keyboard Shortcuts
- Click Add
- Enter any Name: Play or pause Spotify
- Paste in the Command:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
- Click Apply
- Click Disabled on the right so it changes to New Shortcut…
- Press the Pause/Break key
- Click Close
- Listen to music in Spotify and press the Pause/Break key to pause or play the music.
See the Mabishu post to see how to check the other commands you can hook up to other keys.
(Tested with Ubuntu 10.10 and Spotify for Linux preview 0.6.291)