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

0

5 Answers 5

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.
15
  • 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, 2018 at 15:59
  • 9
    9. Rename .desktop file to OBTAINED-VALUE.desktop (e.g. jetbrains-phpstorm.desktop instead phpstorm.desktop), works in Ubuntu 18.04 Jul 12, 2018 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, 2019 at 12:03
  • 3
    @marts Please go through this for an explanations: askubuntu.com/questions/367396/…
    – pomsky
    Jan 26, 2019 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, 2019 at 12:57
10

Ubuntu 20.04 on Wayland

  1. Press Alt + F2
  2. Type "lg" and hit Enter (Looking Glass)
  3. Click on the "Windows" tab.
  4. You should see the titles of all your windows. Below each one you will find a wmclass property. Write down or copy the value you see.
  5. Open up the .desktop config file corresponding to your application. It should be in the ~/.local/share/applications/ folder.
  6. On a new line add StartupWMClass=VALUE_FROM_ABOVE

In my case for Firefox it was "Firefox Developer Edition" and I had to add the line below to my .desktop file:

StartupWMClass=Firefox Developer Edition
7
  • 1
    wmclass does not work for Ubuntu 21.10, instead StartupWMClass worked for me.
    – shvahabi
    Mar 24, 2022 at 21:01
  • 1
    Good catch @shvahabi, would you like to make that an edit on the answer? Just so stackoverflow gives you credit for the edit. Mar 24, 2022 at 21:35
  • No, since there are already answers below with same detailed explanation.
    – shvahabi
    Mar 24, 2022 at 21:54
  • 1
    I think "wmclass" was more likely an error I made when writing this answer. I updated the answer to avoid further confusion. Mar 25, 2022 at 1:57
  • 1
    I like this solution because is points to the existence of "looking glass" feature.
    – brett
    Dec 8, 2023 at 16:25
4

related to :

Kile icon buggy in left (launcher) bar (ubuntu 18.04)

On ubuntu 18.04

  • open the file : org.kde.kile.desktop
  • at : /usr/share/applications
  • add this line at the end of file : StartupWMClass=kile
  • press ALT+F2, r

It works for me

1
  • This keeps working for Ubuntu 20.04. I hope it will be solved in Ubuntu 22.04.
    – jqueralt
    May 21, 2022 at 11:12
2

In my case with Adobe Reader 9 on Ubuntu 20.04, the function StartupWMClass=Acroread works instead of wmclass=Acroread

1
  • Your answer as is right now needs some clarification. Nov 4, 2021 at 22:58
1

In my case, I followed @Chris Hayes, method of finding the WMClass and update the file, see below for an example. I referred other *.desktop files in /usr/share/applications and found that Ubuntu 20.04 is using "StartupWMClass" as the variable and NOT "WMClass". I could not find the Icon for this application so I had to download from the internet a jpeg file icon from Google Image search, save it in the path and assign to the variable "Icon". Please note, I believe this field "StartupWMClass" is case sensitive

[Desktop Entry]
Name=PDFStudioViewer2020
Comment=View pdf documents
Keywords=pdf;ppdf;
StartupNotify=true
Terminal=false
Type=Application
Categories=Application;Office;Viewer;X-Red-Hat-Base;
MimeType=application/pdf;application/ppdf;
Icon=/opt/pdfstudioviewer2020/pdfstudio_internet_icon.jpeg
Exec=/opt/pdfstudioviewer2020/pdfstudioviewer2020 %F
StartupWMClass=PDF Studio Viewer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .