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/