GNOME stop detecting opened desktop apps instances on dash to dock

Sometimes GNOME's dash to dock add-on loses open app instances and launch a new one, when I already am using one instance, this is not a workspace issue because the apps are opened in same workspace. It just loses tracing of what is open and launches again and it's very anoying.

It is happening on Ubuntu 20.04.2 LTS and GNOME Shell 3.36.9

Anybody knows what it could be??


Solution 1:

If you are using Xorg, Gnome uses an app's WM_CLASS property to locate the instances of an app. Every application has a .desktop file and there is a field named StartupWMClass. Gnome reads this field to identify the app's instances. Some applications do not include the StartupWMClass field in its desktop file. This might be causing the issue. To fix it follow these steps:

  1. Go to /usr/share/applications folder and search for the app's name. You will find a desktop file associated with that app, let's say foo.desktop. Copy that file to ~/.local/share/applications (~ stands for the user's home directory).

  2. Open the affected app. Open up a terminal and run xprop WM_CLASS. The cursor will change to a plus sign. Then click on the affected app. A line will be printed to the terminal something like: WM_CLASS(STRING) = 'foo'

  3. Now open the copied file in step 1 using a text editor. At the end of the file add a line StartupWMClass=<wm_class>. Replace wm_class with the output you got in the previous step without quotes. eg.- StartupWMClass=foo

Save the file, then relaunch the app and the problem should be fixed.

Note that this will only work in Xorg because AFAIK, Wayland doesn't require the StartupWMClass property.