Home RSS icon Posts RSS icon Microblog

Notes on getting autostart working for a classic confined snap

Last night I finally managed to get a working build of the Snippet Pixie snap that pretty much works as hoped, but there were a couple of things I had to change in order to get autostart working that I thought it might help others to mention here.

Snippet Pixie snap

There's a couple of wrinkles due to naming.

The snap is called snippetpixie and uses that in the snapcraft.yaml apps: entry, but the binary and canonical name for the app (as used in meson build etc.) is com.github.bytepixie.snippetpixie, and that's the app's "ID" too. It's a GTK app built with Vala, initially for elementary OS.



elementary OS

This means the .desktop file is usually called com.github.bytepixie.snippetpixie.desktop. So in the app it uses this as the desktop file name when trying to copy and fix it up to create an autostart version, but the DesktopAppInfo class failed to find the file by that name.


Turns out snapd/snapcraft takes that com.github.bytepixie.snippetpixie.desktop file and renames it to snippetpixie_snippetpixie.desktop at some point (I think install time by snapd), making some changes to the Exec line along the way.

This means the DesktopAppInfo class doesn't recognise com.github.bytepixie.snippetpixie.desktop as valid.

In the end I had to add specific code for running as a snap to change the desktop file name to look for, and also be careful about the way the Exec line is changed for the new autostart version to carefully insert the required --start param in the altered command line instead of blindly changing it to com.github.bytepixie.snippetpixie --start.

You can see some of the altered (not very clever, but it works) code in snippetpixie's update_autostart function.


Hope this helps someone else having troubles getting autostart to work for a snap.

One More Thing...

I guess I'm also officially announcing that there's candidate availability of a snap for Snippet Pixie!

snap for Snippet Pixie

It can be installed from the candidate channel with…

sudo snap install snippetpixie --classic --candidate

Any feedback on the snap is warmly welcomed via either the Snapcraft forum's "Call for testing" post, or Snippet Pixie's GitHub Issues.

Call for testing

GitHub Issues

Get It!!!




"Notes on getting autostart working for a classic confined snap" was published on May 18, 2019.