Application icon doesn't work in the launcher

I have already asked this on Stackoverflow with no answers or suggestions:
https://stackoverflow.com/questions/52248316/application-icon-doesnt-work-with-snap-packaging

The thing is that the application launcher always shows the system default application icon instead of the icon I set in the .desktop file. I use the same install locations and files for Debian packaging successfully so I guess they are correct.

Source code is here if someone gets interested:

Running ./scripts/buildSnap.sh builds the snap package.

1 Like

I noticed that your plugs: don’t list the desktop or desktop-legacy interfaces which I think will be required.

1 Like

According to my experience, additional patching is required to make the icon visible, here’s a GNU Sed script I been using for this purpose: https://github.com/Lin-Buo-Ren/snapcrafters-template-plus/blob/master/snap/utilities/patch-desktop-entries.sed

Utility script for patching: https://github.com/Lin-Buo-Ren/snapcrafters-template-plus/blob/master/snap/utilities/patch-desktop-entries.bash

Location in-recipe that calls the utility script: https://github.com/Lin-Buo-Ren/snapcrafters-template-plus/blob/5bb7778/snap/snapcraft.yaml#L137-L144

Also, I would like to point out that not all applications in a single snap will prefer a single icon, that’s probably why the Icon key in the desktop entries are not patched in the first place, because Snapcraft doesn’t know what the proper icon belongs to a certain menu entry. This probably should be handled by the packager themselves.

NOTE: The actual desktop entry effective are in /var/lib/snapd/desktop and is generated by snapcraft according to the desktop entry specified in the desktop key of an apps instance.

Where is this all documented? Now I feel that I’m the first one ever who is trying to make this work. Wtf.

1 Like

Unfortunately that doesn’t seem to fix it…

This is the most relatable topic I can find in the doc category, unfortunately, it didn’t mention anything about application icons…

Here’s another one that actually explains some stuff:

1 Like

Change that might work out… or not:

maybe the desktop entry is also needed to be copied to gui/_snap_name_.desktop and patched manually according to the documentation

Yeah, I’ll try that next.

1 Like

I filed a proposal to improve the situation: Proposal: The `apps.<app-name>.icon` Key

I just couldn’t make that work. Should I refer to gui/heimer.desktop somehow in the snapcraft.yaml ?

I don’t think so, the apps.<app-name>.desktop key only allows relative paths from the prime folder. AFAICS the /snap/gui folder will be copied to /prime/meta/gui by snapcraft, so setting apps.<app-name>.desktop key to meta/gui/heimer.desktop might work (never done that before :-/)

Hmm…if I remove /var/lib/snapd/desktop/applications/heimer_heimer.desktop the icon is shown…

Are you sure that menu entry isn’t the other installation of Heimer in your system?

Well, $ find /usr -name "*heimer*" doesn’t give me anything. But I don’t know how the things are cached.

Btw, I can find these files after installation (seems to be correct?):

/snap/heimer/x2/usr/share/icons/hicolor/64x64/apps/heimer.png /snap/heimer/x2/usr/share/pixmaps/heimer.png /snap/heimer/x3/usr/share/icons/hicolor/64x64/apps/heimer.png /snap/heimer/x3/usr/share/pixmaps/heimer.png /snap/heimer/x1/usr/share/icons/hicolor/64x64/apps/heimer.png /snap/heimer/x1/usr/share/pixmaps/heimer.png

Should these have something to do with the path in the desktop file?

Desktop file /var/lib/snapd/deskop/applications/heimer_heimer.desktop now has:

[Desktop Entry] Name=Heimer GenericName=Mind map application Comment=Mind map application Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/heimer_heimer.desktop /snap/bin/heimer %U Icon=heimer Type=Application Categories=Education; StartupNotify=true

Is this now still the same file I have in the yaml ? Not the one that’s under gui/ ? I don’t understand why the Icon is again heimer, but the Exec has been changed :slight_smile:

I’ve

Snapcraft has patched the Exec key but not the Icon key. I’m currently building your snap and experimenting how snapcraft deal with the icon keyword, hold on a bit :wink:

1 Like

Here’s the pull request that is confirmed working: Snap: Fix-up application icon lookup by Lin-Buo-Ren · Pull Request #21 · juzzlin/Heimer

%E5%9C%96%E7%89%87

1 Like