AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.18k stars 2.27k forks source link

Not possible to have icon working for Ubuntu 24 / .Net 8 #16250

Open drweb86 opened 4 months ago

drweb86 commented 4 months ago

Describe the bug

Avalonia UI application built for Ubuntu 24.04 cannot have icon in .Net 8.

To Reproduce

I tried to use __AvaloniaDefaultWindowIcon and ApplicationIcon and both ways show same wheel icon after running application in it.

If you have VM with Ubuntu, execute: wget -O - https://raw.githubusercontent.com/drweb86/butil/master/sources/ubuntu-install.sh | bash Then double click icon on desktop Butil Then see in task bar invalid wheel icon.

Expected behavior

Application icon is visible

Avalonia version

11.0.11

OS

Linux

Additional context

Ubuntu

maxkatz6 commented 4 months ago

AFAIK, some Linux desktops ignore window icon and instead use package icon. Can't test if it's the case here.

drweb86 commented 4 months ago

Thanks, ill try to add package icon and see. I thought icon os taken from window.

drweb86 commented 4 months ago

Unfortunately that did not work. Probably Ubuntu does not support avalonia windows and icons.

kekekeks commented 4 months ago

Thanks, ill try to add package icon and see. I thought icon os taken from window.

That heavily depends on the DE, i. e. GNOME is known for ignoring freedesktop standards. It should still fall back to the window icon though.

drweb86 commented 4 months ago

I created issue for Gnome DE, let them implement support if they want https://discourse.gnome.org/t/feature-request-support-desktop-file-icons/22139

drweb86 commented 4 months ago

Gnome team helped with icon. I post here 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 both shortcuts (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