0

I wrote a systemd user unit to start xscreensaver, since I want it to start up automatically. Here's what it looks like:

# ~/.config/systemd/user/xscreensaver.service
[Unit]
Description=XScreensaver

[Service]
Type=simple
ExecStart=/run/current-system/sw/bin/xscreensaver -no-splash
Restart=always

[Install]
WantedBy=multi-user.target

This starts up; however, it's not following the configuration that I'd laid out (as it does when I just start it manually). I think this is because the HOME directory isn't being set (xscreensaver looks in ~/.xscreensaver for its configuration). But even adding in a line

Environment=HOME=/home/username

in the [Service] section in my unit doesn't fix this; it's still not reading the configuration file. As far as I know, xscreensaver doesn't have a command-line argument to customize the path to the config file. What do I need to do to communicate the correct home directory to xscreensaver?

EDIT: after closer inspection, it seems that xscreensaver is looking at the right config file; however, it's simply just not displaying any of the images (my configuration is just GLSlideshow pointing at a directory). It might be that it's failing to find something in the path that it's looking for?

1 Answer 1

0

OK, I figured this one out. The problem was that GLSlideshow was expecting something (not exactly sure what) to be callable on its PATH, and systemd wasn't giving it the path. So what fixed it was:

[Unit]
Description=XScreensaver

[Service]
Type=simple
ExecStart=/run/current-system/sw/bin/xscreensaver -no-splash
Restart=always
Environment=HOME=/home/myusername
Environment=PATH=/run/current-system/sw/bin

[Install]
WantedBy=multi-user.target

(Note that the /run/current-system/sw/bin path is specific to my distribution, NixOS. It's possible that for more standard systems, e.g. ones that use /bin or /usr/bin, that this wouldn't come up.)

1
  • Perhaps you want to add /run/current-system/sw/bin to PATH in /etc/profile or so. I don't think you need to set Environment=HOME= in a user unit either. Also multi-user.target doesn't really make sense for a user unit (I doubt you can make it practically enabled this way). You probably want default.target instead.
    – Tom Yan
    Commented Mar 18, 2016 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .