Autostart not working and I'm not sure how to debug why

I’m developing a new application (https://github.com/tom-james-watson/Emote) which will be published as a snap.

The app requires autostart in order to function properly, however I’m having trouble getting it working. As far as I can tell from the docs, all I need to do is to add a autostart: <name of .desktop file> to the app section of snapcraft.yaml. I’ve done this but it doesn’t seem to do anything.

Here’s my snapcraft.yaml:

So I have a few questions:

  1. Is there something obviously wrong with my config that is making this not work?
  2. What exactly does the value of autostart do? Is emote.desktop simply telling snapcraft to look for that file in $SNAP_USER_DATA/.config/autostart/? If so, am I meant to be manually moving my emote.desktop to $SNAP_USER_DATA/.config/autostart/emote.desktop as part of the build process? Looking at other apps’ configs online, I can’t see that being done anywhere. Or, does the value mean that snapcraft is going to automatically move my emote.desktop file to that location in the build process? In that case how does it know where to copy emote.desktop from?
  3. Is it a bug that the documentation lists autostart under parts and not app? https://snapcraft.io/docs/snapcraft-parts-metadata#heading--autostart. If it’s parts, why do I need to put it under the apps section in snapcraft.yaml?

Many thanks in advance for your help!

You need to provide a desktop file for autostart that you copy into $SNAP_USER_DATA/. config/. autostart

See this commit as an example:

https://gitlab.gnome.org/Community/Ubuntu/gnome-software/-/commit/23536aac34890104f734920512715c78cc4ea230

Check out my implementation of start on system startup here : https://github.com/keshavbhatt/BingWall
look into mainwindow.cpp file for run_onstartup() function at line no. 594 and snapcraft.yaml file also.

I hope it will help.

I’ve just fixed that. Thanks for letting us know. @degville I cut and pasted the autostart block to the correct location. It might need a bit of word massaging to indicate that it is up to the snap to create the desktop file for automatically starting the app. i.e. the autostart: line is insufficient by itself, and snapd requires the snap to create the file in the right place.

Thanks, Daniel! I think a change like that to the docs would help make this clearer.

And thanks @keshavnrj and @kenvandine - I’ve managed to get it working now with the following change - https://github.com/tom-james-watson/Emote/commit/f85589d345f4c91966e9d24600c2b52abc9f46bb

1 Like

Great, glad you figured it out.

Thanks for moving this Daniel, and sorry autostart was in the wrong place to begin with.

1 Like