Distributing a Desktop GUI application for Linux while reaching the widest possible audience is complicated. Typically, the user has to make sure the correct version of the GUI toolkit is installed and configured. When a Linux distribution changes the delivered GUI toolkits, this can be problematic for applications.
Snaps solve these problems and ensure the correct toolkit libraries are shipped alongside the application at all times.
Read the documentation of the GUI toolkit your application uses in order to get started!
|Common GUI Toolkits||Technologies|
|GTK 3||OpenGL/GPU support|
|GTK+ 2||Desktop Launchers / Menu entries|
|Qt 5 and KDE Frameworks||XDG desktop portals|
|Java Swing||AppStream metadata support|
|Electron||chromium-ffmpeg in third-party browser snaps|
|Flutter||The desktop interfaces|
Compared to CLI apps, desktop apps typically require three additional features.
Since snap apps are completely sandboxed by default, they cannot play sound, create notifications, or access the X server to display itself. However, it’s easy to make this possible by using the the desktop interfaces. These allow you to “poke holes” in the sandbox, to give your application selected access to the host system.
The sandbox also means that your app cannot use the GUI toolkits of the host system. The snap either has to include the toolkit in the snap itself, or it needs to connect to a snap that provides these toolkits. Many toolkits and general desktop features such as fonts and themes also require initialization before the application can start. The
snapcraft-desktop-helpers make this as easy as possible. They provide parts to bundle or access common GUI toolkits in your snap and a
desktop-launch script which does the required initialisation for you.
These methods are not recommended anymore but might be useful as reference.
Last updated 6 days ago. Help improve this document in the forum.