Intro

I recently noticed the Spotify linux port for CentOS, available from Negativo17.org, doesn't acknowledge pressing space to toggle pause and play.

Looking into keybindings felt overly complicated, so some searching later I found a post in the Spotify Desktop Linux forum.

What it basically amounts to, is sending dbus-commands to the Spotify player.

Since these are regular CLI-commands, they could be assigned to custom Panel buttons, and hey presto, we have easily accessible Spotify player controls!

 

Guide

Let's dig into it!

 

Command reference

For starters, these are the available commands.

Play

$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play
Pause

$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause
Play-pause toggle

$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
Previous

$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
Next

$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

 

Fire up the Spotify cllient, and try them out as-is on a command line!

There is no need to have the Spotify window focused.

Works nicely doesn't it!

 

 

Adding button controls

I use the Mate desktop environment (DE) on my personal CentOS 7-desktop , but the Panel works in a similar fashion for most DE's.

Let's start with a Play-pause toggle button.

 

  1. Right-click a free space on the panel where you want the buttons to be placed and click Add to panel.

    Screenshot from 2018 12 07 14 11 05.cropped

  2. Mark Custom Application Launcher and click Add at the bottom.

    Screenshot from 2018 12 07 14 11 43

  3. A Create Launcher-window pops up.
    1. Enter a (preferrably) descriptive name in the Name-field.
    2. Copy the entire Play-pause command line from above and paste it into the Command-field.
    3. Change the icon as needed. I chose the icons from /usr/share/icons/mate/256x256/actions, specifically these;
      Play-pause: gtk-cancel.png (couldn't find a suitable play-pause button so this had to do).
      Previous: go-first.png
      Next: go-last.png
    4. Click OK to save.
    5. Your new shortcut should now be visible on the panel.

      Screenshot from 2018 12 07 14 12 58

  4. Repeat the steps for Previous and Next as needed.

  5. You are now done. Try out the new buttons. The Spotify window still doesn't need to be focused for the buttons to work.

    Screenshot from 2018 12 07 14 13 21.cropped

 

 

 

Conclusion

Not to difficult as workarounds go IMHO.

  • Adding shortcuts to the panel buttons should work if you have the correct desktop environment.
  • For Mate, I haven't found any particular way to assign keyboard shortcuts yet, unfortunately.

 

 

Sources

https://negativo17.org/spotify-client/

https://community.spotify.com/t5/Desktop-Linux/Basic-controls-via-command-line/m-p/4360856#M15590

 

 

 

 

 

 

 

Stop Spam Harvesters, Join Project Honey Pot

 

Get a free SSL certificate!

 

The leading nonprofit defending digital privacy, free speech, and innovation.

 

The Linux Foundation provides a neutral, trusted hub for developers and organizations to code, manage, and scale open technology projects and ecosystems.

 

Kubuntu is an operating system built by a worldwide community of developers, testers, supporters and translators.

 

 43ef5c89 CanonicalUbuntudarktext