14

I am on Ubuntu 16.04, I cannot play, pause, go to the next or the previous song in spotify. There are many answers but most are complicated, is there a simple solution that doesn't require a command line?

I have a Logitech bluetooth keyboard.

21

There is a simple solution credit goes to this thread on Spotify forum, Thanks to schuellerf and rszabla. The solution is pretty simple and works on any Linux distribution.

  1. Download this file, extract it and make it executable chmod a+x spotify_control
  2. Place it anywhere you want, I'll assume that it is placed in Downloads folder
  3. Go to settings -> keyboard -> keyboard shortcuts -> custom shortcuts

enter image description here

  1. Add new shortcut by clicking the plus button, I'll override the default play/pause/next and previous keys because I only listen to music on spotify, If you need those shortcuts then assign different ones for Spotify

enter image description here

The command you see in the picture above is for 'play/pause' function

/home/your_username/Downloads/spotify_control playpause

The commands that are available

  1. /home/your_username/Downloads/spotify_control playpause
  2. /home/your_username/Downloads/spotify_control previous
  3. /home/your_username/Downloads/spotify_control next
  4. /home/your_username/Downloads/spotify_control play
  5. /home/your_username/Downloads/spotify_control stop

Please note that you have to do this

/home/your_username/Downloads/spotify_control playpause

Because

~/Downloads/spotify_control playpause

That won't work, at least not in Ubuntu 16.04, unity desktop, the shortcut manager doesn't seem to understand the tilde ~

  • 3
    this worked for me, thx! quick info of my system: ubuntu 16.04 and using an apple (wired)keyboard – mithril_knight Jan 4 at 18:02
  • What about "Don't Play This Song" shortcut for playlists? – Barbaros Alp Aug 23 at 11:36
13

Here is another link i have found that help me and its the same solutions as k2shah mention it, but with more details.

Instead of downloading the spotify_control, you use the D-Bus commands. Before you add it as a new keyboard command, feel free to execute those commands.

Play/Stop

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

Next

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

Previous

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

Once you validate the above commands, feel free to add them as Key Shortcut. For Ubuntu, "Settings > Devices > Keyboard" than add (+) and put the name and copy the commands, than put the keyboard shortcut.

TheLink

  • for next/prev worked like a charm, but for play/pause the audio play/pause key shortcut it doesn't work. If I remap it to 'super + ;' or other modifier + non-func key works. Any idea as to why? – Lucas Vasconcellos Czepaniki Sep 13 at 5:24
  • Check if that map is already taken for something else. – IvanAK Sep 13 at 11:06
2

If you don't want to download a file and keep it around (for whatever reason) you can just assign the key to the command that's run in the file

I set up a new custom keybind

Name: Spotify Play/Pause

Command:

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

for the other commands just replace the PlayPause with Stop, Next, or Previous

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.