Snap/Core24: Desktop Files and Desktop Environment integration (Generic Icons on taskbar and/or frame)
I am working with Obsidian (the markdown editor). Recently, we have revamped our snap taking advantage of the new core24 pipeline of electron-builder. This has solved some long standing issues, however we have noticed new ones.
This thread is specifically about snaps and their integration with desktop environments under Wayland (which is enabled by default since circa Electron 38).
The setup
- desktopName, Wayland’s app_id are set to
md.obsidian.Obsidian(following the convention of using FQDN),StartupWMClassis also set tomd.obsidian.Obsidianwithin the.desktopfile. - The snap produced by electron-builder (v26,
syncDesktopName=true) has a templatemeta/gui/md.obsidian.Obsidian.desktopwithin the .snap. (NOTE: There is a separate issue that two desktop files are created see here) - When the snap is installed, it (snapd?) creates
/var/lib/snapd/desktop/applications/obsidian_md.obsidian.Obsidian.desktop(frommeta/gui/md.obsidian.Obsidian.desktop).
The problem (Generic Wayland icon)
The observed behavior when running Obsidian on (K)Ubuntu 26.04:
- GNOME: Icon in taskbar is generic wayland icon, icon in application switcher (alt-tab) is generic wayland
- KDE: Icon in taskbar in correct, icon in application frame and in the application switcher (alt-tab) is generic Wayland (See this KDE-BR-466599)
- XFCE: users also report problems, but I haven't tested.
What window managers expect
- If I manually rename
/var/lib/snapd/desktop/applications/obsidian_md.obsidian.Obsidian.desktoptoobsidian_obsidian.desktopGnome works, but KDE still has the same problems. - If I manually rename
/var/lib/snapd/desktop/applications/obsidian_md.obsidian.Obsidian.desktoptomd.obsidian.Obsidian.desktopeverything works everywhere.
Why the problem specifically with Snaps
It seems that snapd creates .desktop files in /var/lib/snapd/desktop/applications/ using the pattern {snapname}-{originaldesktopfile}.desktop.
All other package formats we support (deb, flatpak) install a md.obsidian.Obsidian.desktop and that works everywhere.
The Solution?
I hope my understanding of the problem is correct. I am not sure what the solution to this problem is. Specifically, I am not sure:
- If electron-builder should do something special while building the snap OR
- If this is something that snapd should handle with some manipulation at installation time OR
- If desktop environments have to become "snap" aware in their search for a match, that is the DE also searches for
obsidian-md.obsidian.Obsidian.desktop.
Link to SnapCraft forum topic.
Source: electron-userland/electron-builder