Snapd mangling desktop file exec line

I have a snap in the edge channel in the store called mgba. It contains two executables, for which there is a store assertion, as per my request.

mgba is the command line launcher. mgba-qt is a graphical frontend. I have created a desktop file which launches the qt gui, thus.

[Desktop Entry]
Version=1.0
Icon=${SNAP}/meta/gui/mgba-qt.png 
Exec=mgba-qt
Terminal=false
Type=Application
Name=mGBA
GenericName=Game Boy Advance Emulator
Comment=Nintendo Game Boy Advance Emulator
Categories=Game;Emulator;
MimeType=application/x-gameboy-advance-rom;application/x-agb-rom;application/x-gba-rom;
Keywords=emulator;Nintendo;advance;gba;Game Boy Advance;

Upon install on a target machine things have gone awry. The exec line is missing. Is snapd trying to do something ‘clever’ here? Is this due to my alias? I have tried numerous options but can’t get snapd to leave the exec line working.

$ cat /var/lib/snapd/desktop/applications/mgba_mgba-qt.desktop 
[Desktop Entry]
Version=1.0
Icon=/snap/mgba/7/meta/gui/mgba-qt.png 
Terminal=false
Type=Application
Name=mGBA
GenericName=Game Boy Advance Emulator
Comment=Nintendo Game Boy Advance Emulator
Categories=Game;Emulator;
MimeType=application/x-gameboy-advance-rom;application/x-agb-rom;application/x-gba-rom;
Keywords=emulator;Nintendo;advance;gba;Game Boy Advance;

1 Like

The desktop file needs to start with the typical snap application executable name (the same name it ends up inside /snap/bin), no matter if it has an alias or not.

The reason snapd needs to parse and ensure conformity of this file is that we need to ensure the line is pointing to the right application and that it is confined. Otherwise that Exec line might be doing just about anything on the system, no matter how confined the application is.

I’m not sure I understand.

The filename is mgba-qt.desktop. The exec line is Exec=mgba-qt. I have an alias for mgba-qt in the mgba snap. So based on your response I’m not sure what I’m doing wrong that’s getting undone by snapd on install?

@popey Every snap application has a particular name that you use in your snapcraft.yaml and ends up in snap.yaml inside the snap. That name is the one the desktop file must be named after, and that name is also what needs to be used as the first argument of the Exec line. Aliases are irrelevant here.

In particular, if the application name is bar and the snap name is foo, the line must start like:

Exec=foo.bar
1 Like

Given that the intent of the author would be to have a desktop file presented to the user, shouldn’t this be an error instead of a silent removal?

FWIW, I have been asking for that to be the case ever since desktop files were introduced into snapd.

1 Like

It certainly would have saved some time if I’d had an error message rather than a broken desktop file.