Desktop file couldn't created

Hi everyone! I’ve the next snap folder structure

snap
├── gui
│ ├── deletebg.desktop
│ └── icon.png
└── snapcraft.yaml

deletebg.desktop contains:

[Desktop Entry]
Name=deletebg
Exec=bin/java -jar $SNAP/jar/deletebg-2.0.4.jar
Icon=${SNAP}/meta/gui/icon.png
Type=Application

In snapcraft.yaml:

apps:
deletebg:
extensions:
- gnome-3-28
command: bin/java -jar $SNAP/jar/deletebg-2.0.4.jar
plugs:
- desktop-legacy
- desktop
- home
- network

If I don’t add desktop field in apps, the .desktop file is copied to the meta/gui/ folder as a result it creates the icon on desktop, but it doesn’t work.

If I add desktop: meta/gui/deletebg.desktop" I get the error:

Failed to generate desktop file: Invalid desktop file ‘meta/gui/deletebg.desktop’: does not exist (defined in the app ‘deletebg’).

There is no deletebg.desktop file in prime folder anywhere. But how can I to do this or what did I wrong?

Your Exec= value should match the command that would run your snap via the CLI, for example, the firefox snap would just put Exec=firefox there, I’d presume yours might just be Exec=deletebg

It didn’t help. I got the same error

Just to be clear, is that error that the .desktop file still doesn’t work or that you get failed to generate .desktop file still.

You don’t need to have the desktop file entry in the yaml if you have the configuration you have in the top half of the post, in which case I’d have expected the Exec= change to have worked.

That’s it! You were right! we don’t need the desktop field in snapcraft.yaml if we have desktop configuration file. I just made a little typo in my exec command :slight_smile:

So, I have the deletebg.desktop configuration:

[Desktop Entry]
Name=deletebg
Exec=deletebg
Icon=${SNAP}/meta/gui/icon.png
Type=Application

and apps in snapcraft.yaml

apps:
deletebg:
extensions:
- gnome-3-28
command: bin/java -jar $SNAP/jar/deletebg-2.0.4.jar
plugs:
- desktop-legacy
- desktop
- home
- network

Thank a bunch! :slight_smile: