I can run redshift from a command line, but can't get it working in systemd. The steps in a similar question didn't do the trick for me.
Ubuntu 16.04.
My redshift.service:
$ cat /etc/systemd/system/redshift.service
[Unit]
Description=restrict blue light
After=graphical.target
[Service]
ExecStart=/usr/bin/redshift -v
Environment=DISPLAY=:0
[Install]
WantedBy=graphical.target
If I run /usr/bin/redshift
from the command line it starts recoloring my screen. If I try to start the service it dumps:
$ sudo systemctl status redshift
● redshift.service - restrict blue light
Loaded: loaded (/etc/systemd/system/redshift.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-09-16 21:23:51 PDT; 4s ago
Process: 4676 ExecStart=/usr/bin/redshift -v -l 37.35:121.99 (code=exited, status=1/FAILURE)
Main PID: 4676 (code=exited, status=1/FAILURE)
Sep 16 21:23:51 cyberpower-linux redshift[4676]: Initialization of randr failed.
Sep 16 21:23:51 cyberpower-linux redshift[4676]: Trying next method...
Sep 16 21:23:51 cyberpower-linux redshift[4676]: No protocol specified
Sep 16 21:23:51 cyberpower-linux redshift[4676]: X request failed: XOpenDisplay
Sep 16 21:23:51 cyberpower-linux redshift[4676]: Initialization of vidmode failed.
Sep 16 21:23:51 cyberpower-linux redshift[4676]: Trying next method...
Sep 16 21:23:51 cyberpower-linux redshift[4676]: No more methods to try.
Sep 16 21:23:51 cyberpower-linux systemd[1]: redshift.service: Main process exited, code=exited, status=1/FAILURE
Sep 16 21:23:51 cyberpower-linux systemd[1]: redshift.service: Unit entered failed state.
Sep 16 21:23:51 cyberpower-linux systemd[1]: redshift.service: Failed with result 'exit-code'.
If I run xhost +
and try to start again, it does start coloring the screen. How can I give my systemd script access to my window server without giving everything access to my window server?
Thanks in advance for any clues...