How can i add a daemon in a flatpak?

Dylan McCall dylan at endlessos.org
Sat Aug 13 01:08:23 UTC 2022


You can use the Background portal to create an autostart file for your
application at runtime:
https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Background.
This isn't as robust as, say, a systemd service, but it works nicely for
desktop applications.

For example, here's where GNOME Break Timer sets up autostart with the
background portal:
https://gitlab.gnome.org/GNOME/gnome-break-timer/-/blob/master/src/settings/BreakManager.vala.
Note there are some wrinkles because we need to ask permission from the
user and we can't be sure they will allow it.

Pika Backup is another app which uses the Background portal:
https://gitlab.gnome.org/World/pika-backup /
https://gitlab.gnome.org/World/pika-backup/-/blob/main/src/ui/utils.rs.

Alternatively, if this is an optional feature and you really want a systemd
service, you can always have that as an extra step. So, structure your
flatpak in such a way that the background service you want is a command you
can run inside that container, then provide an example systemd service file
which a user could install. But that way lies dragons, so I hope the
background portal will do the trick.

Hope that helps!

Dylan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/flatpak/attachments/20220813/1aaa0f27/attachment.htm>


More information about the Flatpak mailing list