Integrating desktop applications with snaps has been a little bit challenging in terms of getting them looking and behaving as part of the system. This means following general desktop theming, having global application menu integration, getting the icon caches, getting configuration keys and such. Also, the technologies and toolkits like GTK, Qt, demand a little bit of expertise on that front.
That’s the reason why we saw flourishing some desktop helpers like gtkconf or qtconf as cloud snapcraft parts for this. However, they were sharing little code and some part of the integration was working for one flavor and not the other flavor and vice-versa.
New desktop launchers to the rescue!
This is the reason why we are announcing new destkop launchers! The goal was to streamline the experience and ensuring that all following user visible features are working, independent of the toolkit or technology you are using:
- Bind with current desktop theme if shipped by default (GTK & Qt)
- Icons theme available for decoding (with the right decoders automatically shipped)
- Application menu integration (in Unity)
- Icon cache and images generated on first launch (no more need to ship pre-compile GSettings and Gio caching modules) after a new upgrade
- Keep previous xdg-based data, even after upgrade
- GSettings keys available for reading (not only writing)
- Most of the code is shared between the launchers, so any fix in one will benefit others, and we assemble them at build time.
- Avoid erratic behavior like cd $SNAP that some launchers were doing and not others (we don’t change the current working directory anymore)
Those new cloud parts also ship with default package set configuration to ensure all features are enabled, this is overridable as well, as explained by Sergio in his blog post.
Qt-based applications also show those drastic improvements. Note that the appmenu fix for Qt applications will only work starting with snapd 2.0.10.
Definition and usage
We currently have 5 launchers, depending on the technology you want to support: gtk2, gtk3, qt4, qt5 and glib-only for a lightweight, non graphical app, but needing basic integration like GSettings and MIME types.
Those are grouped under the "desktop" namespace from the snapcraft cloud part functionality, with extensive help on how to use them:
(Note that the descriptions are for now common to any namespaces launchers)
Migrating from gtkconf/qt4conf/qt5conf
As part of this journey, I wanted to see this applied in the real world and migrated all snappy playpen examples to this new launchers. I was delighted to see that some of the goals, like having smaller snapcraft.yaml was a success. Also, broken examples are now fully integrated to the desktop (see some of the pictures above).
Migrating is the existing gtkconf/qt4conf/qt5conf (we plan to deprecate them after a while) is a 2 minutes job:
- Replace: after: [<xxx>conf] with after: [desktop/<xxx>] where <xxx> is the targeted toolkit.
- Change command: gtk-launch (or qt-launch) foo with commands: desktop-launch foo. For simplicity, all launchers are now called "desktop-launch". Note that foo needs to be in $PATH for your snap, if it’s not, replace it to $SNAP/foo.
- You can (not mandatory) clean up any build-packages or stages-packages that are shipped and expose in the desktop launcher definition.
By following those simple steps, you can get from an unthemed, no matching icons and no appmenu VLC to a fully integrated one!
Happy snap desktop integration! 🙂
Learn how the Ubuntu desktop operating system powers millions of PCs and laptops around the world.