Dot net executables and missing desktop task bar icons for Ubuntu Gnome Wayland

Hello

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.

I’ve created a bug for Avalonia, but they tell, support for icons in Gnome is incomplete.
Not possible to have icon working for Ubuntu 24 / .Net 8 · Issue #16250 · AvaloniaUI/Avalonia (github.com)

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.

Thank you.

I have no idea what “Avalonia UI icons” are. Is that an image format? Desktop icons are typically PNG or SVG; see:

This is already implemented.

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.

Thanks, I’ll investigate it.

Icons are .ico files.

ICO files are not really supported as icon assets on Linux, seeing as they originated as a Windows icon format.

Thank you for soo fast response. I see that ico files are recognized as icons on Desktop , but not for running applications.

So I will try to put .png icon instead of .ico files and see it it will work.

Running applications must have register themselves with an application identifier that matches their desktop file; see: Integrating with GNOME

The toolkit you are using must support this functionality.


Seems like even with .png file, png icon is not used for launched application.

As I understood, GNOME still tries to resolve icon from somewhere else apart from .desktop file.

I found this topic.
App icon specified in .csproj file doesn’t appear on app windows on (at least) Kubuntu Linux and Linux Mint · Issue #5329 · AvaloniaUI/Avalonia (github.com)

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.

Thanks.

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

Thanks @skeller, @ebassi

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.