how to automate redshift? [solved]

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
squid

how to automate redshift? [solved]

Post by squid »

I'm a noob, I've tried writing a cronjob/script the cronjob below isn't working but the standalone command works.

Code: Select all

redshift -gtk -o


what should i change here below to make it work?

Code: Select all

* 19 * * * /usr/bin/redshift-gtk -o 3000
* 4 * * * /usr/bin/redshift-gtk -x
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
1000
Level 6
Level 6
Posts: 1039
Joined: Wed Jul 29, 2020 2:14 am

Re: how to automate redshift?

Post by 1000 »

You can use Cron or Autostart
viewtopic.php?f=18&t=333839&p=1911005&h ... n#p1911005

This is very old example setup from system (setup autostart from system from Graphic Environment)
https://www.youtube.com/watch?v=obR3zxvXGWI

Warning
There are two applications
redshift this app working from terminal
redshift-gtk app with GUI

and

Code: Select all

$ redshift-gtk --help
Run `redshift -h` for help 
So I have doubts if the options in the video will work, you need check if you want use.
I may be wrong.

Edit
Example for Cron
with redshift-gtk which you can test, but you need edit path "/user_name/" and "user_name"

Code: Select all

@reboot      sleep 10 && export DISPLAY=:0.0 && export XAUTHORITY=/home/user_name/.Xauthority && sudo -u user_name /usr/bin/redshift-gtk
1000
Level 6
Level 6
Posts: 1039
Joined: Wed Jul 29, 2020 2:14 am

Re: how to automate redshift?

Post by 1000 »

This tutorial is interesting
https://www.maketecheasier.com/protect- ... ift-linux/

but there is gtk-redshift

Code: Select all

$ locate redshift | grep bin |  xargs  ls -l
lrwxrwxrwx 1 root root    12 gru 27 13:23 /usr/bin/gtk-redshift -> redshift-gtk
-rwxr-xr-x 1 root root 71912 gru 27 13:23 /usr/bin/redshift
-rwxr-xr-x 1 root root   986 gru 27 13:23 /usr/bin/redshift-gtk
so on Linux Mint 20.1 I have in system link to redshift-gtk.
So "gtk-redshift" command should also work.
User avatar
AZgl1800
Level 20
Level 20
Posts: 11180
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: how to automate redshift?

Post by AZgl1800 »

I just have Redshift installed, then manually set it for the way my eyes feel.
I set up custom short cuts.

______________________________________

Redshift Evening redshift -O 4500
Redshift Bedtime redshift -O 3700
Redshift Morning redshift -O 6500
Keyboard Custom shortcuts have to be created to make this work.


Redshift.png
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: how to automate redshift?

Post by Welcome »

squid wrote: Wed Feb 03, 2021 10:12 am I'm a noob, I've tried writing a cronjob/script the cronjob below isn't working but the standalone command works.

Code: Select all

redshift -gtk -o

what should i change here below to make it work?

Code: Select all

* 19 * * * /usr/bin/redshift-gtk -o 3000
* 4 * * * /usr/bin/redshift-gtk -x
Both 1000 and AZgl1500 have provided excellent solutions. Using 1000's information, I found that the following cron settings work perfectly for me with one monitor:

Code: Select all

0 19 * * * export DISPLAY=:0 && /usr/bin/redshift -o 3000
0 4 * * * export DISPLAY=:0 && /usr/bin/redshift -x
If you have multiple monitors, you'll need something like this to specify the monitor to control (note the extra ".0" on DISPLAY):

Code: Select all

0 19 * * * export DISPLAY=:0.0 && /usr/bin/redshift -o 3000
0 4 * * * export DISPLAY=:0.0 && /usr/bin/redshift -x
You may notice that I'm using the command "redshift" and not "redshift-gtk". The command "redshift" is the binary that you'll want to use. The command "redshift-gtk" is a python script that calls redshift, but provides the system panel control and may use the file ~/.config/redshift.conf if you've created it. If you've activated redshift-gtk, I recommend that you "Quit" the app if you're using cron with redshift (see the little lightbulb icon in your lower right system panel, right click, select "Quit")..

Finally, I've found that I needed a little gamma correction on my test machine, so I added the gamma correction as follows:

Code: Select all

0 19 * * * export DISPLAY=:0 && /usr/bin/redshift -o 3000 -g 0.7:0.7:0.7
0 4 * * * export DISPLAY=:0 && /usr/bin/redshift -x
The method used by AZgl1500 is an excellent solution and gives a lot of control over when to use your settings. But, if you want a more automated method, I've found the use of the ~/.config/redshift.conf file and the redshift-gtk program to be very useful. It can be set to autostart on boot, and it'll automatically adjust the screen based on your lat/lon location (that is, it knows when sunrise and sunset occurs for you on every day of the year and adjusts automatically). Here's an example of that file:

Code: Select all

; Global settings
[redshift]
temp-day=6200
temp-night=3500
transition=1
gamma=0.7:0.7:0.7
location-provider=manual
adjustment-method=vidmode

; The location provider and adjustment method settings
; are in their own sections. This is an example of a manual setting.
[manual]
lat=37.2
lon=-88.1

; In this example screen 0 is adjusted by vidmode. Note
; that the numbering starts from 0, so this is actually
; the first screen.
[vidmode]
screen=0
If you use redshift-gtk, don't use the cron solution (and vice-versa). Doing both could cause problems.

I hope this helps. If your question has been answered, please edit the title of your first post in this thread and add <SOLVED> so that others will know that you've found a solution.
Locked

Return to “Scripts & Bash”