Click on Ubuntu 21.04 icons (left navigation) opens new icon rather than adding a red dot [duplicate]

My OS:

Distributor ID: Ubuntu
Description:    Ubuntu 21.04
Release:        21.04
Codename:       hirsute

Note that I do not use the Wayland display server protocol that's used by default by Ubuntu 21.04. Since this is apparently buggy in the current version I had to switch back Xorg. How that's done is described here.

In Ubuntu's navigation on the left every new instance of a program is indicated by another red bullet next to it, so the number of bullets tells how many instances are open. In case of thunderbird, for example, every new email window also gets another dot. For some programs (like kile, but also others) that does however not seem to work as shown here:

bug for kile

You can see that the kile program icon (in blue) which is part of the navigation -- and onto which I clicked to open it! -- does not show any red bullets. Instead it opens another instance (which correctly gets the red dot), and this one uses a default icon. Clearly that's a bug/wrong! How can this be resolved? As said, this behavior is not specific to kile, it also happens with others.

Please also note that this seems (extremely) closely related to the following StackOverflow post, though that one also does not have any answer (and although it's also in Ubuntu 21.04, it seems to still use Wayland). I do not regard it a duplicate, since there are differences: That post talks about this phenomenon when creating a new starter on the desktop, which is not what I did. I just click on the correct icon in the navigation. (And as said: I deactivated Wayland, which the other user apparently didn't.)

What's causing that and how can it be fixed?


Solution 1:

  1. Install the xprop tool if you don't have it.

    sudo apt install x11-utils
    
  2. Get the WM Class of your Kile application.

    Launch Kile.

    Open a terminal, and execute the following:

    xprop | grep WM_CLASS
    

    The cursor will change to a cross ("+") shape. Click on the headerbar of your Kile window with this cursor.

    In the terminal, y ou will see an output like:

    WM_CLASS(STRING) = ...
    

    Note this value.

  3. Update your *.desktop file.

    In the terminal, execute:

    sudo nano /usr/share/applications/org.kde.kile.desktop
    

    Scroll to the end of the file, press Enter to add a new line, and type the following. Replace <WM_CLASS> with the value you noted from step 2.

    StartupWMClass=<WM_CLASS>
    

    Press CtrlX, then Y, and then Enter to save your changes and exit the Nano editor.

Now, when you launch Kile, you will see one icon in the dock (multiple) indicators for running instances.