spotify desktop app on ubuntu 20.04

In this post I show you how to add playback controls to the Spotify icon on the Ubuntu dock.

Admittedly, we’re not short of ways to control Spotify in Ubuntu. There is the MPRIS2 music applet in the notification shade, the app itself has player controls, and like most distros Ubuntu support keyboard media keys too (though mine don’t work).

But this is also true of Rhythmbox, Ubuntu’s default music app. Yet that app also comes with a right-click “quick list” menu in its dock item that makes it easy to skip forward, back, or pause music entirely.

I wanted something similar for the native Spotify Linux app.

So I added one:

screenshot of dock options for spotify on ubuntu in GNOME Shell
Without, and with: you can add these actions easily

Now, I can right-click on the Spotify icon in the Ubuntu dock to access Play/Pause, Next, Prev, and Stop actions – no need to unfurl the notification shade to access the media player controls there, or try and refocus the app to take control.

Y’know how I got it working?

I read tutorial I wrote in 2016 about doing something similar with the Unity launcher. A few tweaks to that code was all it took to make it work in GNOME Shell and the Ubuntu Dock (though the player controls will also show in Dash to Dock, Dash to Panel, and many others).

The process is easy enough: open the spotify.desktop file in /usr/share/applications and paste in the relevant actions linking to the mpris2 controls. Save. Done.

Though, as pointed out to me down in the comments, you may prefer copying the desktop file to your local directory first. This will stop any future updates to Spotify from overwriting the changes you make.

How to do it

As I like to dramatically re-theme Spotify I use the Spotify app from the official Spotify repo rather than the Snap app. It’s fine if you don’t; this method will work with the official Spotify Snap too, you’ll just need to edit the .desktop file in a different location.

If you use the Spotify Snap app the same process also works, just copy the Spotify .desktop file located in /var/lib/snapd/desktop/applications and edit that instead.

To create add player controls to the Spotify dock item in Ubuntu first copy the Spotify desktop launcher to your local apps folder:

cp /usr/share/applications/spotify.desktop ~/.local/share/applications/

Next open the file in Gedit (or a text editor of your choice):

gedit ~/.local/share/applications/spotify.desktop

In the text editor window APPEND the following text underneath the existing test in the Spotify .desktop file:


[Desktop Action Play/Pause]
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

[Desktop Action Next]
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

[Desktop Action Previous]
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

[Desktop Action Stop]
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

It’s super important that you do not replace any of the existing text already in this file or add anything else (accidentally or intentionally). Errant characters in a .desktop file can stop it from working.

Once you’re happy, hit save.

That’s the hard part over!

Next, remove the Spotify icon from the Ubuntu Dock (or Dash to Dock, Dash to Panel, etc whatever you’re using) and log out and back in (if you use GNOME on Xorg you can press Alt + F2, type r, and hit enter to avoid logging out).

Once you’re back in, search for Spotify in your preferred app launcher and add it back to your dock/launcher.

Now, when open, you can right-click on the launcher item to access your newly added actions.

I haven’t tried this with the Spotify Flatpak, so I don’t know if this also works there. If you try it out, let me know how you get on.

In short, a quick and easy way to add player control options to the Spotify dock icon.

How To gnome shell quicklists spotify ubuntu dock