This method is not recommended anymore. These instructions are outdated.
Please use the
gnome-3-28extension instead. It does everything explained here automatically, and it contains a number of improvements. See GTK3 applications for a complete tutorial on how to use the extension.
GTK3 for snaps using
The GTK3 libraries are available in the
gnome-platform content snap and the snapcraft desktop helpers project provides the
desktop-launch script to configure the environment for GTK3.
First copy the definition of the
desktop-gnome-platform part from the Snapcraft Desktop Helpers
snapcraft.yaml into your Snapcraft recipe, in the
parts section. Change the
source property of this part to
# This part installs the `desktop-launch` script which initialises desktop
# features such as fonts, themes and the XDG environment.
# It is copied straight from the snapcraft desktop helpers project. Please
# periodically check the source for updates and copy the changes.
<please copy the rest of this part from the desktop helpers snapcraft.yaml>
desktop-launch script in the app command.
command: bin/desktop-launch $SNAP/bin/audiocoder-gtk
Add the following plugs to connect your snap to the
gnome-platform snap for the GTK libraries and the
gtk-common-themes snap for common GTK themes. This uses the content interface to mount files of the
gnome-platform and the
gtk-common-themes snaps into your snap.
# GTK libraries
# Common GTK themes
Finally, connect your snap to the following desktop interfaces so it has permission to access desktop functionality.
Snapcraft will warn you several libraries are not found in the snap and the base snap as some of them are provided via the
gnome-platform content snap instead. Disregard those warning and only add the libraries that are really missing from the snap to the
Take a look at the GTK3 Demo snap for a fully working example.
GTK3 for snaps without
base property set
GTK3 applications should reference the
desktop-gtk3 remote part.
In this snippet, the remote part is referenced as a null part:
# You may optionally override parts of the remote part definition
snapcraft define _remote_part_name_ to check out the remote part’s definition.
In addition, the launcher script which sets up the environment should prepend the actual app command 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