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:

image
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:

image

mkdir -p /tmp/xairedit
wget -P /tmp/xairedit --content-disposition \
"https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=xairedit" \
"https://aur.archlinux.org/cgit/aur.git/plain/xairedit.desktop?h=xairedit"
. /tmp/xairedit/PKGBUILD
wget -P /tmp/xairedit $(eval echo \${source_$(arch)})
sha256sum -c << EOI
$(eval echo \${sha256sums_$(arch)}  /tmp/xairedit/*.tar.gz)
EOI
sudo mkdir -p /opt/xairedit
sudo tar -C /opt/xairedit -z -x -f /tmp/xairedit/*.tar.gz
desktop-file-install \
--dir=${HOME}/.local/share/applications \
--remove-key=TryExec \
--set-key=Exec --set-value=/opt/xairedit/X-AIR-Edit \
--set-key=Icon --set-value=/opt/xairedit/X-AIR-Edit_icon.png \
--set-key=StartupWMClass --set-value=X-AIR-Edit \
/tmp/xairedit/xairedit.desktop
1 Like

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:

I’ve tested the above code in a #f37 VM and it works just fine.

The Filesystem Hierarchy Standard defines /opt as the appropriate place for third-party add-on software, in accordance with well-established practice since UNIX days.

I don’t recommend editing desktop files manually as it may result in various issues, including the inability to validate file structure and properly update icon and mime caches.