0

I am writing a tool (zxcV32/OpenRWC) that fetches wallpapers from Reddit and sets them to the monitor(s) using nitrogen.

To make it easy to install and run automatically, I have created a deb package and a systemd service.

When the service is started using

sudo systemctl start openrwc@$USER.service

nitrogen errors out with exit status 1. (No other error message). And yes, the exec installed by the deb package works fine when manually run from the terminal.

I have compared that the command run by the tool is precisely the same when run through the systemd service or terminal run.

Sample command

nitrogen --set-scaled /home/zxcv32/.config/OpenRWC/fz41kmzk1wj91.jpg --head=0   

Service

[Unit]
Description=Reddit Wallpaper Changer for GNU/Linux
Requires=display-manager.service
After=display-manager.service
StartLimitIntervalSec=0

[Service]
Type=simple
ExecStart=/usr/bin/openrwc
Restart=always
RestartSec=5
User=%i

[Install]
WantedBy=graphical.target

What may be wrong with the service? I want the service to be the user's choice, if they want to run it or not.

BTW I found this question that claims that nitrogen works through a service. (maybe there is a difference between running nitrogen directly through system service and through a go funciton)

System: Debian 11 5.10.0-17-amd64

zxcV32
  • 74
  • 1
  • 4
  • The question: How to run systemd service every hour but also everytime user logs in? https://forum.endeavouros.com/t/how-to-run-systemd-service-every-hour-but-also-everytime-user-logs-in/27134 – zxcV32 Aug 26 '22 at 15:22
  • I’m voting to close this question because From the tag: systemd questions should be for *programming questions* using systemd or its libraries. Questions about *configuring the daemon* (including writing unit files) are better directed to Unix & Linux: https://unix.stackexchange.com. – Rob Aug 27 '22 at 11:18

1 Answers1

0

Found the issue.

Systemd does not have access to certain environment variables.

DISPLAY environment variable needs to be set in the openrwc@.service.

[Service]
Environment="DISPLAY=:0"
zxcV32
  • 74
  • 1
  • 4