简体   繁体   中英

Nitrogen through systemd services doesn't work

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM