Desktop App Support - GTK


Graphical applications which use the GTK+ Toolkit require additional libraries and environment configuration to function correctly inside a snap.

The details have been collected into a remote part, which can be included in any snap at build time.

GTK2 based applications should use the desktop-gtk2 remote part. GTK3 applications should reference the desktop-gtk3 part.

In this snippet the remote part is referenced in an after section.

        after: [desktop-gtk3]

In addition the launcher script which sets up the environment should prefix the binary name in the apps section. Typically it’s also necessary to specify the full path to the target binary after the launcher.

   command: desktop-launch $SNAP/usr/bin/audiocoder-gtk
       plugs: [network, desktop, desktop-legacy]

These pre-defined parts do not automatically pull in all necessary GTK libraries, but the minimum required by most applications.

The developer is expected to list any further libraries as stage-packages or additional parts.

Importing PIL and gi into a Snap
How can I build package with python and gtk?
Proposed new documentation outline
Questions regarding the usage of the gnome-platform content snaps

I think it would be helpful to link this back to Bundling runtime dependencies - Libraries


Should there also be minimal example to define .desktop file integrated into the snapcraft.yaml. Gtk apps need to have a .desktop entry in order to run correctly in snap.


Great article, I would like to see some info on using the gnome-platform content snap though.


The unofficial Snapcrafters Template Plus has implemented an example desktop entry:


Does [desktop-gtk3] still apply when using a base? such as base: core18 ?

When using a base, I get an error: Cannot find the definition for part ‘desktop-gtk3’


When using bases, snapcraft no longer support remote parts. You need to redefine the part. You can see below for an example. Going forward snapcraft will include an extension for “gnome” which provides what the remote part did, however that isn’t done yet.