Ubuntu – Duplicate (Spotify) Icon in launcher

iconslauncherspotifyunity

I have installed spotify on Ubuntu 13.04 and have locked the icon on the launcher. But when I exit the program fully or even restart and use that icon to open spotify, a new icon is created or a different icon is generated with a ? on it.

It is a clean install of Ubuntu 13.04 so was wondering if this is a known bug or if there was a way of making sure it just doesn't created a duplicate icon?

N.B it has not happened as of yet to any other program I have installed (Chrome & Steam)

Best Answer

It is a bug, this is a partial workaround.

To workaround quit out using the launcher (or just closing the window) and relaunch leaving the indicator in the top menu running) even with the desktop file below results seem inconsistent and buggy.


Create a new launcher that has StartupWMClass=Spotify defined.

You can make a spotify.desktop file with these contents:

[Desktop Entry]
Name=Spotify
GenericName=Music Player
Comment=Listen to music using Spotify
Icon=spotify-client
Exec=spotify %U
TryExec=spotify
Terminal=false
Type=Application
Categories=Qt;Audio;Music;Player;AudioVideo
MimeType=x-scheme-handler/spotify
StartupWMClass=Spotify

Or edit the orginal from /opt/spotify/spotify-client/spotify.desktop (requires superuser permissions) adding the line StartupWMClass=Spotify at the end

Save it somewhere you can keep it like "Documents". Then drag it to the launcher.

This will make sure that the windows with the WMClass named spotify will open under that icon.

Code to get WMClass of a window:

xprop|grep WM_CLASS

This returns the following when clicking on the spotify window:

WM_CLASS(STRING) = "spotify", "Spotify"

(This seems to only partially solve the issue, completely exiting will probably end up with two icons again)

Note: I noticed that the problem started happening less and less the more I launched it - this is probally due to my system having preload installed, it might help: https://apps.ubuntu.com/cat/applications/preload/

Related Question