Snap icons and menus

Hey,

How do I get my snap to appear in window manager menus, with an icon?
Here is a simple project that does not currently work: https://upload.run/egzune

I followed the instructions here: https://docs.snapcraft.io/build-snaps/metadata

What do I need to change in that project to get it working?

Anyone? There must be something obvious that i am missing here…

Can you put the assets onto a repo maybe?
I suspect that you might be missing a desktop file.

What do you mean, assets? Move my icon and .desktop file into another folder?

I have a .desktop file in the ”gui” folder, are you saying that i need more than one?

Can you share just the desktop file here in a post?

[Desktop Entry]
Name=icontest
Comment=icontest
TryExec=icontest
Exec=icontest %U
StartupNotify=true
Terminal=false
Type=Application
Icon=${SNAP}/meta/gui/icontest.png
NoDisplay=true
Name[en_US]=icontest.desktop

What ended up working in my case…

a path relative to the prime directory pointing to a desktop file

(found in https://docs.snapcraft.io/build-snaps/metadata)

Aha! I built the snap on my machine and went looking for the myproject.desktop file in the prime folder snapcraft creates when building the snap. The original lives in the data folder in my project but snapcraft copied it over to a subfolder in its prime folder. Once you have that location you can add it to your snapcraft.yml config:

---- 8< ----
apps:
  myproject:
    command: desktop-launch myproject
    desktop: share/applications/myproject.desktop
---- 8< ----

With the path being the relative path within the prime directory.

I am no snapcraft expert, YMMV.

Do you mind sharing a working snapcraft.yaml ?
I get this when i build mine using the modified project that I posted:

The path 'prime/share/applications/icontest.desktop' set for 'desktop' in 'icontest' does not exist.

Where exactly is this ‘data’ folder supposed to be in my folder structure?

edit: and how am I supposed to know this when it isn’t in the documentation?

Ok I finally got it.

I was looking in the wrong direction. The problem was actually the .desktop file missing some entries, as @sergiusens might have suggested in the future…