As part of the effort by the Ubuntu desktop team to migrate another application to a strict confinement snap, we are running up against problems with the way snapd names desktop files for applications. In particular, it is a problem for handling desktop notifications in gnome-shell.
This isn’t the first time people have run into problems with the current naming scheme:
- Desktop file names
- Telegram Snap Unity Integration
- Phisical button to open gnome-calculator not working
- Mpris can not be used with Snaps
In most of these cases you could argue that the application developer should adapt to snapd’s way of doing things, but I don’t think that holds for the notifications case. I’ll describe my reasoning for that in a follow-up post so as not to bog down the proposal.
The common use case here is for applications that want to use the same identifier for their desktop file and a bus name they acquire on the D-Bus session bus. This is also commonly used as an AppStream identifier, which snaps can currently provide via the
So I propose that if a snap provides any desktop files in
meta/gui that are named like
common-id + ".desktop" for any of the snap’s apps, that they be installed without the
$snapname_ prefix. Further more, that these desktop files be associated with the app in the same way a
$snapname_$appname.desktop file would.
This obviously introduces the possibility for naming conflicts where they didn’t previously exist, so snapd should refuse to install/upgrade a snap if the
common-id desktop file is provided by another snap, which can be done by checking the
X-SnapInstanceName key in the existing file.
It is also incompatible with parallel installs of a snap, but many desktop applications will try to acquire a particular D-Bus name. So they are likely already incompatible with parallel installation.
To achieve this, I think the following changes would be necessary:
As we’re actually making use of the AppStream ID, we should perform actual validation of the field beyond that it is unique within a given snap. The specification provides some guidance, but we might want to check the two AppStream libraries too. We should check the existing corpus of snaps against whatever validation rules we decide on.
wrappers.AddSnapDesktopFilesshould recognise desktop files whose name matches a
common-idfor the snap and install them without the snap name prefix. A check should be added that we aren’t overwriting a desktop file owned by a different snap.
Rather than using a
wrappers.RemoveSnapDesktopFilesshould remove all desktop files with a matching
cmd.ClientAppInfosFromSnapAppInfosshould check for the existence of a desktop file named for the
common-idof the app, and include it in the