You are not logged in.
Pages: 1
Hi all, long time user and first time poster. I'm running bunsenlabs based on Debian Jesse, dual booting with Windows (unfortunately), and I have this funny problem. Here's the scoop:
I installed the program redshift to reduce eyestrain while working at night, and wanted to make a script to run it at startup. I made the following script file in init.d called redshiftstart:
#! /bin/sh
# /etc/init.d/redshiftstart
# /usr/bin/redshift
### BEGIN INIT INFO
# Provides: redshift
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: shift redly
# Description: redly shift
### END INIT INFO
usr/bin/redshift -l 42.604252:-72.556478 2000:3000
The command executes when I run the script file, or when I plug the command directly into terminal. I then went through the basic process of getting a script on one of the startup levels:
sudo chmod 755 /etc/init.d/redshiftstart
sudo update-rc.d redshiftstart defaults
And rcconf confirms that the symbolic link exists and has been activated. And yet! When I reboot, nothing happens. This is the result of systemctl:
semaphore@hellworld:~$ systemctl status redshiftstart service
● redshiftstart.service - LSB: shift redly
Loaded: loaded (/etc/init.d/redshiftstart)
Active: failed (Result: exit-code) since Thu 2016-01-21 09:26:35 EST; 13min ago
Process: 499 ExecStart=/etc/init.d/redshiftstart start (code=exited, status=1/FAILURE)
● service.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Have I overlooked something obvious? Thanks for your help.
Offline
I guess you will have to change your script so it responds correctly giving it an argument of start, stop, reload....
See e.g. the startup scrip for 'motd'.
Offline
If you are using systemd, just use systemd units -- they are easier to write than at least init scripts with LSB headers.
Here is the one I use for redshift:
[Unit] Description=redshift [Service] ExecStart=/usr/bin/redshift -m randr -l manual -t 6250:3400 -l 35.67:139.75 -g 1.2:1.2:1.2 KillMode=process KillSignal=SIGTERM
Place in $HOME/.config/systemd/user as redshift.service, and then you can start/stop it using `systemctl --user start redshift.service`, or place in /etc/systemd/user and control with just `systemctl start` etc. You also need to make sure to set the DISPLAY variable in order for redshift to be able to connect to the X server. For your systemd user session, do
systemd --user import-environment DISPLAY
in a session startup script for your window manager of choice (at least this part is also missing in your LSB init script). Alternatively, do call redshift like so:
/usr/bin/env DISPLAY=:0 redshift $other $parameters
Thanks for your help, I'm starting to understand but still having trouble. I removed my old script (and corresponding symbolic link) from init.d, and made the file you use in both /etc/systemd/user and $HOME/.config/systemd/user (for testing). The command 'systemctl --user start redshift.service' goes through but does nothing; the command 'systemctl start redshift.service' fails to load: 'no such file or directory. I rebooted and ran the reload daemon, no changes.
I haven't set the DISPLAY variable as you said yet, that might be the problem; this install is pretty fresh and I believe I'm just using openbox, but I'm not sure where to find/put the startup script of which you speak.
EDIT: 'systemctl status redshift.service' returns 'Loaded: not-found (Reason: No such file or directory)'
Last edited by semaphore (2016-01-21 17:08:18)
Offline
'systemctl status redshift.service' returns 'Loaded: not-found (Reason: No such file or directory)'
If you wish to run the script for all users, place the custom unit file in /etc/systemd/system
Offline
semaphore wrote:'systemctl status redshift.service' returns 'Loaded: not-found (Reason: No such file or directory)'
If you wish to run the script for all users, place the custom unit file in /etc/systemd/system
thanks, it finds the script now, but I get this message back
semaphore@hellworld:~$ systemctl status redshift.service
● redshift.service - redshift
Loaded: loaded (/etc/systemd/system/redshift.service; static)
Active: failed (Result: exit-code) since Thu 2016-01-21 21:10:21 EST; 27s ago
Process: 1269 ExecStart=/usr/bin/redshift -l 42:-72 2000:3000 (code=exited, status=1/FAILURE)
Main PID: 1269 (code=exited, status=1/FAILURE)
thank you all again for your patience and help.
Offline
So what is the output of:
systemctl status redshift
To investigate further, add your user to the systemd-journal group:
sudo gpasswd -a USER systemd-journal
newgrp systemd-journal
Replace USER with your actual username.
Then post the output of:
journalctl _PID 1269
Note that if you have rebooted since your last post the PID (1269) will be different -- check the `systemctl status` output to get the current PID of the .service
Offline
So what is the output of:
systemctl status redshift
To investigate further, add your user to the systemd-journal group:
sudo gpasswd -a USER systemd-journal newgrp systemd-journal
Replace USER with your actual username.
Then post the output of:
journalctl _PID 1269
Note that if you have rebooted since your last post the PID (1269) will be different -- check the `systemctl status` output to get the current PID of the .service
In all these quotes below, checking redshift and redshift.service outputted the same thing, so I'm just including one of them for clarity. I rebooted, added myself to the journalers, and conducted the following:
semaphore@hellworld:~$ systemctl status redshift
● redshift.service - redshift
Loaded: loaded (/etc/systemd/system/redshift.service; static)
Active: inactive (dead)
semaphore@hellworld:~$ sudo systemctl start redshift.service
[sudo] password for semaphore:
semaphore@hellworld:~$ systemctl status redshift.service
● redshift.service - redshift
Loaded: loaded (/etc/systemd/system/redshift.service; static)
Active: failed (Result: exit-code) since Fri 2016-01-22 09:32:49 EST; 7s ago
Process: 953 ExecStart=/usr/bin/redshift -l 42:-72 -t 2000K:3000K (code=exited, status=1/FAILURE)
Main PID: 953 (code=exited, status=1/FAILURE)
Jan 22 09:32:49 hellworld redshift[953]: `RANDR Query Version' returned error -1
Jan 22 09:32:49 hellworld redshift[953]: Initialization of randr failed.
Jan 22 09:32:49 hellworld redshift[953]: Trying next method...
Jan 22 09:32:49 hellworld redshift[953]: X request failed: XOpenDisplay
Jan 22 09:32:49 hellworld redshift[953]: Initialization of vidmode failed.
Jan 22 09:32:49 hellworld redshift[953]: Trying next method...
Jan 22 09:32:49 hellworld redshift[953]: No more methods to try.
Jan 22 09:32:49 hellworld systemd[1]: redshift.service: main process exited...RE
Jan 22 09:32:49 hellworld systemd[1]: Unit redshift.service entered failed ...e.
Hint: Some lines were ellipsized, use -l to show in full.
The lines that showed up at the end are precisely what showed up in the journal when I checked it (this only started happening after I added myself to the journal viewers -- it's pretty nifty). It looks like redshift itself is failing -- which confuses me deeply, because I can plug the command into terminal and it runs no problem.
Thank you again!
Offline
I suspect redshift is started too early. The X server needs to be up, so that randr vcan do its job.
To test if my guess is correct, try running the following command after you have logged into the graphical environment:
sudo systemctl start redshift
Then check its status again.
If that solves your problem, edit your unit file to:
[Unit]
Description=Redshift display colour temperature adjustment
Documentation=http://jonls.dk/redshift/
After=display-manager.service
[Service]
ExecStart=/usr/local/bin/redshift -m randr -l 51.22:2.90 -t 6250:3400 -g 1.2:1.2:1.2
KillMode=process
KillSignal=SIGTERM
Added:
After=display-manager.service
Offline
I suspect redshift is started too early. The X server needs to be up, so that randr vcan do its job.
To test if my guess is correct, try running the following command after you have logged into the graphical environment:sudo systemctl start redshift
Then check its status again.
If that solves your problem, edit your unit file to:
[Unit] Description=Redshift display colour temperature adjustment Documentation=http://jonls.dk/redshift/ After=display-manager.service [Service] ExecStart=/usr/local/bin/redshift -m randr -l 51.22:2.90 -t 6250:3400 -g 1.2:1.2:1.2 KillMode=process KillSignal=SIGTERM
Added:
After=display-manager.service
Thanks for the suggestion, unfortunately I inputted the commands from my previous post after the graphical environment loaded, and it still fails.
Offline
This is the unit supplied by the Arch redshift package:
empty@Arch ~ % cat /usr/lib/systemd/user/redshift.service
[Unit]
Description=Redshift display colour temperature adjustment
Documentation=http://jonls.dk/redshift/
After=display-manager.service
[Service]
ExecStart=/usr/bin/redshift
Restart=always
[Install]
WantedBy=default.target
Try that, I think it's the "Restart=always" that you are missing
EDIT: Change the path to the redshift binary, obviously,
Offline
This works for me in bunsenlabs:
Unit file in /usr/lib/systemd/user/redshift.service
[Unit]
Description=Redshift display colour temperature adjustment
Documentation=http://jonls.dk/redshift/
After=display-manager.service
[Service]
ExecStart=/usr/bin/redshift -m randr -l 51.22:2.90 -t 6250:3400 -g 1.2:1.2:1.2
# Restart=always
[Install]
WantedBy=default.target
After startup run
systemctl --user import-environment DISPLAY
systemctl --user start redshift
Offline
Pages: 1