[systemd-devel] how to use per-user systemd --user services / how to replace /etc/xdg/autostart/app.desktop?

Mantas Mikulėnas grawity at gmail.com
Thu Jun 16 13:03:15 UTC 2016


On Thu, Jun 16, 2016 at 3:32 PM, Patrick Schleizer <
patrick-mailinglists at whonix.org> wrote:

> Hi!
>
> I would like to replace some /etc/xdg/autostart/app.desktop files with
> systemd --user services. I believe these are better because then systemd
> keywords such as 'After=' etc. can be used.
>
> Is this a use case systemd can be used for?
>

Mostly, yes. Various services in GNOME 3.20 now show up under `systemctl
--user`, in fact.

Once the user logs in, the systemd --user service should start. Similar
> to like /etc/xdg/autostart mechanism works.
>
> Using Debian jessie (stable) with systemd package version 215-17+deb8u4.
>
> How to do that?
>

[Install]
WantedBy=default.target

However, making everything start via default.target is not a good idea:

– The actual login is delayed until default.target finishes; there were
suggestions to split it up (making only basic.target the 'blocking' part),
but nobody has written the code for that yet. So large services in
default.target can make logins slow.

– When default.target is processed, services don't yet have the necessary
environment variables (see below).

Is there any difference for a login console and an X session?
>

Not yet, no. (Also no difference between whether the --user manager was
started due to an actual login, or whether it was started on boot due to
"enable-linger" configuration.)

So I would create a separate graphical.target and manually `systemctl
start` it via .xprofile or such. (Don't forget, also, that graphical
programs usually need $DISPLAY, and this is only imported to the --user
manager /after/ default.target has already started.)

I've heard of some plans to make "logging in to GNOME" start gnome.target,
and such, but AFAIK there's nothing concrete yet. (Perhaps when the [kd]bus
wars end.)

Nowhere on search engines I found how to do that with Debian. I also
> asked the Debian systemd package maintainers a while ago [with
> instructions what I did], but did not get an answer. [1]
>

About the same as with other distros. Though it'll work better on stretch
than jessie – among other things, you'll probably want the
"dbus-user-session" package, which adds dbus.service for apps launched via
--user.

-- 
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160616/26873e42/attachment.html>


More information about the systemd-devel mailing list