Creating a desktop file for autostarting within a snapped application

Hello everybody.

I want to implement a new feature for my application (it is a java-based application already snapped and in the store for a while): A checkbox for allowing the application to start automatically when the system is booted. To do so, I need to create a desktop file within /home/myhome/.config/autostart but I obtain Permission denied error everytime I try to write to this directory.

The snap confinement is strict and I have home plugin defined within snapcraft.yaml. This is the complete file:

name: wallpaperdownloader
version: “3.1”
summary: Download, manage and change your favorite wallpapers from the Internet
description: WallpaperDownloader is a simple GUI Java based application for downloading, managing and changing wallpapers from the Internet
grade: stable
confinement: strict

apps:
wallpaperdownloader:
command: wallpaperdownloader.sh
# network-observe plug will be needed to run ping command from the snap
plugs:
- x11
- desktop
- desktop-legacy
- wayland
- unity7
- network-bind
- network-observe
- home
- gsettings

parts:
/snapcraft/parts
wallpaperdownloader:
plugin: maven
source: …
stage-packages:
- mate-desktop-common
- curl
after: [desktop-gtk3]

exec:
plugin: dump
source: scripts

Any ideas if this is possible to do? Thank you very much!

Today this is not allowed, however please see https://github.com/snapcore/snapd/pull/4942. This is targeted for 2.33 but may still yet make it into 2.32.

Hi @jdstrand , thank you very much for the quick answer :slight_smile:

There is something that it isn’t clear for me after reading the link: in order to autostart an snapped application, will it be only necessary to create a .desktop file within /home/myhome/snap/application/version/.config/autostart?

Or some configuration will be needed within snapcraft.yaml file in order to achieve this goal?

Thank you again!!