54

I'm using Ubuntu 17.10 with GNOME shell and Numix-Circle icon theme.

When I hover over the Numix icon for Nightly Web Browser, which is pinned to the dock I get the title "Nightly Web Browser".

enter image description here

But when I launch the program, another icon pops up at the bottom, with the name "Nightly".

enter image description here

pomsky
  • 68,507
Chantz Garrett
  • 603
  • 2
  • 6
  • 7

5 Answers5

81

You need to add a proper StartupWMClass line to the .desktop launcher corresponding to the application (refer to this). Follow these steps:

  1. Open Files and go to your /usr/share/applications folder. Look for the "Nightly" file (i.e. the launcher for the application you want to fix) and copy it.
  2. Paste the file in ~/.local/share/applications. It should look like a file with the name <filename>.desktop.
  3. Right click on this .desktop file and open with Text Editor.
  4. Launch "Nightly" (i.e. the application you want to fix) from "Activities".
  5. Run xprop WM_CLASS in Terminal.
  6. Place the cursor over the opened "Nightly" window. The cursor should turn into a crosshair already. Click. You should get a WM_CLASS string for "Nightly" in Terminal.
  7. In the .desktop file opened in Text Editor add the following line

    StartupWMClass=OBTAINED-VALUE
    

    In place of OBTAINED-VALUE put a value you got from step 6 without any quotes.

  8. Save the .desktop file.
pomsky
  • 68,507
  • 3
    I am trying to do the same with PyCharm. Got "sun-awt-X11-XFramePeer", "jetbrains-pycharm-ce" as the output for step 6. I used StartupWMClass=jetbrains-pycharm-ce and it works. – d4nyll Jan 11 '18 at 15:59
  • 9
  • Rename .desktop file to OBTAINED-VALUE.desktop (e.g. jetbrains-phpstorm.desktop instead phpstorm.desktop), works in Ubuntu 18.04
  • – Aleksey Deryagin Jul 12 '18 at 16:29
  • 3
    Thank you for the answer. It would be really nice to have an explanation of what happens. I don't want to blindly follow some instructions. What is going on and what does the fix do? Would be great if someone could help out. – marts Jan 26 '19 at 12:03
  • 3
    @marts Please go through this for an explanations: https://askubuntu.com/questions/367396/what-represent-the-startupwmclass-field-of-a-desktop-file – pomsky Jan 26 '19 at 12:05
  • 4
    @AlekseyDeryagin In step 6, I got WM_CLASS: not found. As the misbehaving application was kile and the name of the file org.kde.kile.desktop, I just added the line StartupWMClass=kile and it works. My wild guess is that the last full-stop separated part of the filename (right before .desktop) should match the StartupWMClass value. – Ansa211 Feb 11 '19 at 12:57
  • 1
    Fantastic, thank you. Worked with Qt5 Creator on Ubuntu 18.04 (StartupWMClass=QtCreator). – Jason C Jan 10 '20 at 22:56
  • @AlekseyDeryagin My only worry there is if the .desktop file was installed by a package manager, I wonder if it could cause conflicts/confusion in future updates/uninstalls if I forget I renamed it; otoh putting a copy in .local keeps me from touching package files. Do you think that could be an issue? – Jason C Jan 10 '20 at 22:57
  • 1
    As a side note, if you run gnome-shell under Wayland, xprop won't work. You can use Alt+F2 and run 'lg' (look glass). Under the Window tab, you get the WMClass. Notice it works also under X. – alci Apr 16 '20 at 14:11
  • When an Audio CD is in the external USB DVD drive, every time machine resumes from suspend another icon appears in the launcher. The solution is in this answer with the line StartupWMClass="desktop_window", "Nautilus" inserted (Ubuntu 16.04.6 LTS) – WinEunuuchs2Unix Oct 31 '20 at 18:46
  • This solution doesn't work on Ubuntu 20.04 with VS Code. – Jack M Nov 10 '20 at 13:56
  • 1
    it works very well on mine. @Chantz you should mark this answer as accepted if this work for you. – Jacky Supit Mar 24 '21 at 03:09
  • 1
    I've tried all - to no avail. But if I name the desktop file exactly like the WmClass name it seems to work in Gnome. - Strange DE that – kanehekili May 01 '21 at 17:06
  • Some programs (which are listed in my left navigation) are not even listed in the folder /usr/share/applications, so this 'guide' here cannot be followed for them. I suppose that in this case I am supposed to create that file on my own? Is there an easy to follow 'manual' for each required line -- similar to this one? :) – Prof.Chaos Sep 06 '21 at 03:26
  • 1
    @prof It depends on how you have installed those applications. If you installed the snap version of the application, then this would help: https://askubuntu.com/q/1199337/480481. Check this one out if you want to create the .desktop launchers by hand anyway: https://askubuntu.com/q/13758/480481 and https://askubuntu.com/q/1191962/480481 – pomsky Sep 06 '21 at 14:18
  • 1
    Thanks, man! I've fixed my sublime installed from *.tar.bz on Ubuntu 20.04. I've just added StartupWMClass=sublime_text to sublime.desktop) – IStranger Dec 02 '21 at 07:51