I was porting my .Net-8 Avalonia UI application to Ubuntu 24 and faced an issue, that .desktop files created with .ico file reference not used for launched application. While on Desktop and Search i see proper icons, when I start app, this icon is not used. Same icon is used for windows of applications.
Can you please add support for .Net 8 Avalonia applications
a) .desktop icons
If icon is specified, show it in toolbar for launched .net application instead of default wheels icon
b) window icons
If window have icon, can you please use it as icon for toolbar when this window is opened.
This is an X11-specific functionality that does not exist in Wayland (which is the default windowing system for GNOME), at least until the xdg-toplevel-icon protocol gets implemented, and even in that case the icon would come from the icon theme, not from random files.
Basically .Net build toolkit handles icon specified in project file .csproj like this
butil.ico
It does not allow any other extensions, including .png.
It puts it as resource _NET_WM_ICON inside executable.
This property was ignored by GNOME in 2021.
Proposal is to support it - or if icon cannot be fetched from executable - then use .desktop icon from which it was executed.
Is this maybe about the window WM_CLASS (X11) or app_id (Wayland) not being able to be matched to a .desktop file?
You can check in looking glass in the “Windows” section if the window has the right application associated with it. If it does not, make sure the wmclass listed there (which corresponds to the WM_CLASS or app_id) matches the file name (or StartupWMClass) of the .desktop file.
I managed to solve it with this WM_CLASS thing. I post here full solution, in case somebody else will need icon working for Ubuntu Gnome Wayland.
To make icon of process being executed working, you need to create .desktop files based on the following example
File: BUtil.desktop
[Desktop Entry]
Encoding=UTF-8
Version=2024.06.29.8
Name=BUtil
GenericName=Incremental backup, Synchronization, Import media
Categories=Incremental backup;Synchronization;Import media
Comment=BUtil creates incremental backups and imports multimedia on your PC with deduplication and FTPS, SMB/CIFS, MTP transports support for Windows and Linux.
Type=Application
Terminal=false
Exec=/usr/local/butil/butil-ui.Desktop
Icon=/usr/local/butil/Icon 120x120.png
StartupWMClass=butil-ui.Desktop
Icon must not be ICO file, it must be PNG or something else. It should be full path. /usr/local/butil - installation folder for butil app. butil-ui.Desktop - is executable file name. When its specified Ubuntu will detect processes with this name and adjust icon.
Put file into folders:
a) /usr/share/applications - for start up search to work
b) $(xdg-user-dir DESKTOP) - for desktop, should not be executed from root.
Allow system to execute shortcut file (should not be launched from root mode)
sudo chmod -R 775 "${shortcutFile}"
gio set "${shortcutFile}" metadata::trusted true
After that icon will work for both shortcuts and executed executable