Because the xscreensaver service needs to run in a graphical session, it should only be started when the graphical procedures and environment are ready. In the scope of systemd's understanding, the target graphical-session-pre.target makes such sense. We will therefore arrange for the xscreensaver service to start after (
After=) this target.
In addition, the xscreensaver service needs to be installed as part (
PartOf=) of graphical-session.target. The graphical-session.target target will manage the xscreensaver service and will stop the xscreensaver service when the session is terminated.
ExecStart=/usr/bin/xscreensaver -no-splash -no-capture-stderr
The xscreensaver service is now a static service (without the
Install section). We define the target xscreensaver.target to start the service using
Wants=. The target xscreensaver.target also combines to start the graphical-session.target target with
BindsTo=. When the graphic session ends, it also stops the xscreensaver.target target and makes sure the session is terminated clean
At startup, the xscreensaver.target target will be pulled in by the default.target target.
Activation will now be done for xscreensaver.target, not xscreensaver.service
systemctl --user enable xscreensaver.targetShare on Twitter Share on Facebook
systemctl --user start xscreensaver.target
Can't see mail in Inbox? Check your Spam folder.