How to ensure a launcher icon gets linked to the application it launches?

I’m trying to add a launcher for an executable which doesn’t have its own icon when launched on its own. In the .Desktop file I’m setting the icon to use and it shows up correctly, but when I launch it, it just spawns a new entry rather than using the launcher and it also doesn’t have an icon, it just uses some sort of default icon:

668115a99988a7c68141eb83e77facf5263439ea.png
I’ve clicked the icon on the left, but as you can see, it is lacking the white bar which indicates that the application is running. Instead a new icon appears (the one on the right) and it doesn’t even use the correct icon.

This is my .Desktop file btw:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=X-AIR-Edit
Comment=Controller software for digital Behringer mixers
Icon=/home/fedora/bin/X-AIR-Edit_LINUX_1.7/X-AIR-Edit_icon.ico
Exec=/home/fedora/bin/X-AIR-Edit
Terminal=false
Categories=Sound;Media
StartupWMClass=X-AIR-Edit
StartupNotify=true

As you can see I already tried to set StartupWMClass to the WM_Class and Name to the process name, but it’s still not working…

This is how I got the process name and WM_CLASS btw:

$ xprop | grep WM_CLASS
WM_CLASS(STRING) = "X-AIR-Edit", "X-AIR-Edit"

$ ps -ef | grep -i X-AIR
fedora     24638   19660  3 10:27 ?        00:00:04 X-AIR-Edit
fedora     24895   22911  0 10:29 pts/3    00:00:00 grep --color=auto -i X-AIR

Any ideas what I’m doing wrong?

No one? :confused:

This has to match the actual class of the window. In Gnome Shell on Wayland, you can see the class in the looking glass, Windows tab (Alt + F2, lg Enter).

Thanks, but it seems to report the same name as xprop. :confused:

e3f45b2baaa03c311b3265610245c5afc61953df.png

So following your script, my .desktop file should look like this, right?

[Desktop Entry]
Name=X-AIR Edit
Comment=Remote control for Behringer X Air mixers
Icon=/home/fedora/bin/X-AIR-Edit_LINUX_1.7/X-AIR-Edit_icon.ico
Exec=/home/fedora/bin/X-AIR-Edit
Terminal=false
Type=Application
Categories=Audio;Mixer;AudioVideo;
StartupWMClass=X-AIR-Edit

I’m hesitant on actually installing the application into /opt, but I can’t see a reason for why that would make a difference.

Replacing my .desktop file with the above, I still get the same icon behavior. :confused:

Hello,

I know this is an old thread, however, I ran into the same problem and wanted to bring some resolution for any newcomers (like myself). The following worked for me:

Ensuring StartupWMClass exists and set to the correct wm_class in my .desktop file.
I determined the ‘wm_class’ via looking glass: Alt+F2, lg and looking in the 'Window` tab (as discussed above).

At first this didn’t work, however, after logging out and back in I got the proper effect!

I am using Fedora 41 Linux (Workstation Edition) and this was for an app I built locally (i.e. GitHub - lem-project/lem: Common Lisp editor/IDE with high expansibility) with my .desktop file placed in $HOME/.local/share/applications/

Here is my ‘working’ .desktop file:

[Desktop Entry]
Name=Lem
GenericName=TextEditor
Comment=A editor/IDE well-tuned for Common Lisp
StartupWMClass=Lem SDL2
Exec=sh -c "GTK_THEME=Adwaita:dark /home/logoraz/.local/share/common-lisp/source/lem/lem"
Icon=/home/logoraz/.local/share/common-lisp/source/lem/frontends/sdl2/resources/icon.png
Type=Application
Terminal=false
Categories=TextEditor;Utility
Keywords=TextEditor

Best,