[systemd-devel] systemd user unit - how to prepare environment?

Mantas Mikulėnas grawity at gmail.com
Tue Sep 11 07:45:04 UTC 2018


On Tue, Sep 11, 2018 at 10:34 AM Kamil Jońca <kjonca at o2.pl> wrote:

> I post on debian-user, but no answer.
> Maybe here I found some knowledge.
>
> KJ
> kjonca at poczta.onet.pl (Kamil Jońca) writes:
>
> > I tried to setup some user units in my desktop, and have problem with
> > env variables.
> > So far I set them up in custom .xsession file (in home directory)
> > I tried to put
> > something like
> > systemctl --user import-environment NNTPSERVER
> > in my .xsession file, but it looks like this script is run parallel with
> > user units, and I have race condition, ie. some units can't see
> > variables.
> >
> > So my question is, where to init variables for user units?
> > I woluld like to have possiblity to set them as not only as fixed
> > strings
> >
> > (i.e. I would to have PATH=$PATH:xxx)
> >
> > KJ
>
>
Start your units after this is done. That is, don't link them to your
default.target, but call `systemctl --user start foo.service bar.target
quux.service` in the same .xsession file right after importing environment.

(This has some advantages: it doesn't delay the whole login process as
default.target would, and it allows you to start graphical apps as systemd
units.)

-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180911/adde3aa6/attachment-0001.html>


More information about the systemd-devel mailing list