Manually start a target

systemd

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?

Best Answer

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
Related Question