Solved How to run script after "login" and/or after 'login manager'?

Greetings,

In short, I have created a script which suppose to run 'redshift' to alter some gamma etc.
It runs well by starting manually:
sudo /usr/local/etc/rc.d/redshift start

However, it 'never' runs on boot. I also added redshift_enable="YES" to rc.conf
Code:
-rwxr-xr-x  1 root  wheel  344 Oct 14 21:52 redshift
boot log:
Code:
Oct 14 21:57:01 <console.info>  kernel: redshift starting
Oct 14 21:57:01 <console.info>  kernel: Starting avahi-daemon.
Oct 14 21:57:01 <console.info> kernel: `RANDR Query Version' returned error -1
Oct 14 21:57:01 <console.info> kernel: Initialization of randr failed.
Oct 14 21:57:01 <console.info> kernel: Trying next method...
Oct 14 21:57:01 <console.info> kernel: No more methods to try.
Oct 14 21:57:01 <console.info> kernel: Starting hald.

Script:

Code:
#!/bin/sh

# PROVIDE: redshift

. /etc/rc.subr

name="redshift"
start_cmd="${name}_start"
stop_cmd="${name}_stop"

redshift_start() {
   echo "redshift starting"
   # your commands here
   /usr/local/bin/redshift -O 6200 -g 0.7:0.7:0.7 -P &
}

redshift_stop() {
   echo "redshift stopping"
   # your commands here
}

run_rc_command "$1"

# eof
 
It requires a running X, your service is likely starting before X does. Have you tried adding it to your ~/.xinitrc instead?
 
Nice piece of software, wasn't aware of it.

As SirDice said...
Initialization of randr failed.
I just did a quick test and and added the following to my ~/.xinitrc
/usr/local/bin/redshift -l geoclue2 &
restarted Xorg...
Code:
% ps -x | grep redsh
7826  -  S    0:00,11 /usr/local/bin/redshift -l geoclue2
No custom rc script needed ;)

A perfect addition to the icc profile I apply via x11/xcalib in my ~/.xinitrc. I like it :)👍
 
Ah, I see.

I tried, but it still doesn work. I tries also 'redshift-gtk'. Below is my ~./xinitrc file. Did I mess up there something?

cat ~/.xinitrc
Code:
# QT ANTIALIASING
export QT_XFT=1

# QT MUST KNOW WHERE IS GTK2 CONFIG
export GTK2_RC_FILES="${HOME}/.gtkrc-2.0"

# QT5 qt5ct
export QT_QPA_PLATFORMTHEME=qt5ct

redshift-gtk -O 6000 -g 0.7:0.7:0.7 -P &
exec ck-launch-session startkde

It requires a running X, your service is likely starting before X does. Have you tried adding it to your ~/.xinitrc instead?
 
you can always put a sleep of 120 seconds before it in the rc.d , so you have 120 seconds to start x.
I have the following line in .xinitrc,
nohup zsh -c "sleep 2.7 ; redshift -l 50.85:4.35" &
 
120 seconds before it in the rc.d
The rc system is not involved, don't get yourself fooled by an XY problem.

redshift-gtk -O 6000 -g 0.7:0.7:0.7 -P &
Code:
% whereis redshift-gtk
redshift-gtk:
There is no such thing...

Also, did you notice that -O is a one-shot command? Redshift will set this color temperature and then exit.
If that is what you want, a color temperatur of 6000K may not be noticable from the default 6500K, maybe it already worked...
If you want it to run in the background and adjust the color temperature over time, run my simple example inside a terminal in Xorg.
Add -v if you experience problems. Verify using ps, that redshift is running.
 
whereis redshift-gtk
redshift-gtk: /usr/local/bin/redshift-gtk
(I got it from man, it hidden in the port package, compiled from port)
But it doesn't matter, I don't need it's GUI

The rc system is not involved, don't get yourself fooled by an XY problem.

Ok...

" -O " -> this option was intentionally selected (the point is, that I can change the gamma and light values later with redshift command overriding the previous one. If I say run it without, I could end with black screen or too yellow screen.
---
-O TEMP
One-shot manual mode (set color temperature). Use this with the
-P option to clear the existing gamma ramps before applying the
new color temperature.

---

6000K a bit noticeable yes, but gamma values of " -g 0.7:0.7:0.7 " is a big shot.

I can run "/usr/local/bin/redshift -l geoclue2" and "/usr/local/bin/redshift -O 6000 -g 0.7:0.7:0.7 -P" from terminal and it works ok, but ~/.initrc won't and there is no redshift process running.
Code:
% whereis redshift-gtk
redshift-gtk:
There is no such thing...

Also, did you notice that -O is a one-shot command? Redshift will set this color temperature and then exit.
If that is what you want, a color temperatur of 6000K may not be noticable from the default 6500K, maybe it already worked...
If you want it to run in the background and adjust the color temperature over time, run my simple example inside a terminal in Xorg.

Add -v if you experience problems. Verify using ps, that redshift is running.
 
Last edited:
Back
Top