5

I'm using systemctl --user for a lot of user services on my Linux desktop.

One of the things I'm doing (per "Starting A DBus Session Application from systemd User Mode") as a hack to get my environment variables from my session is that I'm running a manual script on startup of the graphical session which calls systemctl --user import-environment. I then have a dummy service which I start via systemctl --user start environment.service. All of my other services which are enabled depend on environment.service.

I figure this would probably make a better target than a service. Is there a way to create a target which must be explicitly started via systemctl --user start user-login-graphical.target?

6
  • Wouldn't it be simpler to just fix your session so you didn't have to employ bizarre hacks?
    – jasonwryan
    Dec 21 '17 at 19:58
  • There's nothing wrong with my session. systemd by default strips out environment variables and so the only way for me to get them into the environment is via the import-environment command. Dec 21 '17 at 20:01
  • 1
    Err, no. Not at all.
    – jasonwryan
    Dec 21 '17 at 20:02
  • 1
    Feel free to disagree with the facts: variables from my graphical session are not imported into systemd userspace units. If I use show-environment, I can see only four or five environment variables. After import, it's closer to 20. I want to be able to launch things in my desktop session from systemd. Dec 21 '17 at 20:54
  • Like I said above, fix your broken session. It's not a systemd issue.
    – jasonwryan
    Dec 21 '17 at 21:00
6

I was able to accomplish this via the following unit file:

[Unit]
Description=User Graphical Login
Requires=default.target
After=default.target

I will then manually start the target as it has no Install section and will not get started on its own.

systemctl --user start user-graphical-login.target
2
  • Done and done . Dec 21 '17 at 23:33
  • Thumbs up for how you manage your session! Been doing exactly the same stuff for years as well... ;) Feb 16 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.