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
You can make a
spotify.desktop file with these contents:
Comment=Listen to music using 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:
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: