Redshift or other screen temp

New features which should be implemented in Porteus; suggestions are welcome. All questions or problems with testing releases (alpha, beta, or rc) should go in their relevant thread here, rather than the Bug Reports section.
nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

Redshift or other screen temp

Post#1 by nanZor » 09 Nov 2023, 21:36

One thing I miss for those late-night Porteus forum reading sessions ... a redshift screen temp built in.

On other systems, I normally utilize the small SCT (or XSCT) commandline to do it:

sct 6500 (for daytime default color)
or
sct 4500 (for nightime hacking)

Usually run as a shell script, or desktop launcher. I'll look around and see if it is in the repos, but wish it came default with the iso's.

UPDATE: picked up xsct_1.9-1.amd64.deb from Debian 12 (Bookworm)
Porteus converted the deb, I popped it into my modules folder, activated it, and tada! (use xsct vs sct) No more late-night bloodshot eyes.... Porteus rocks.
That's a UNIX book - cool. -Garth

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Redshift or other screen temp

Post#2 by rych » 13 Nov 2023, 09:04

Thanks nanZor, that works nicely. Actually the only essential file in that package is the 14Kb xsct binary itself. So I just extracted it and put into my local binaries folder inside /changes -- as a I suspect not every little thing needs to be a module :)

Apparently it can set brightness as well. I used to set brightness with either xbacklight -set 100 or
xrandr --output eDP1 --brightness 1, good to have a 3rd way of doing it.

nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

Redshift or other screen temp

Post#3 by nanZor » 14 Nov 2023, 08:50

Wow rych, I didn't realize it did brightness as well as color shift! Thanks for the tip.

I suppose if I was working in daylight, and *only* wanted to control brightness and not the temp, I'd do the default temp (6500) followed by brightness, ie

Code: Select all

xsct 6500 0.9
xsct 6500 0.5
etc.

But if I was happy with brightness, and just wanted to attenuate the blue light for nightime stuff, something like

Code: Select all

xsct 4500 1.0
I didn't realize I had control over the secondary brightness level. Awesome tip, makes this even more valuable.
That's a UNIX book - cool. -Garth

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Redshift or other screen temp

Post#4 by Rava » 26 Nov 2023, 07:33

I use 023-RedshiftGUI-0.2.4-Linux-x86_64-Fixed.xzmas module since it is light on dependencies.

But it has a bug when storing its setup file that I needed to learn about:
/home/guest/.redshiftgrc map entry needs to be comma-separated instead of | -separated (RedshiftGUI-0.2.4 stores it as invalid | -separated )

Meaning: while you can change the colour temp using RedshiftGUI-0.2.4 in the running system, you have to manually edit /home/guest/.redshiftgrc for the new map to work at next boot and put /home/guest/.redshiftgrc into persistence.
Cheers!
Yours Rava

nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

Redshift or other screen temp

Post#5 by nanZor » 26 Nov 2023, 20:16

Yep - I tried Redshift too, but used a custom config that didn't rely on internet access..

https://wiki.archlinux.org/title/Redshift

However, I was delighted to find the simpler sct, or xsct. I noted that sct only controls redshift, but Xsct will also do brightness. It's my goto!
That's a UNIX book - cool. -Garth

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Redshift or other screen temp

Post#6 by Rava » 26 Nov 2023, 20:21

nanZor wrote:
26 Nov 2023, 20:16
I noted that sct only controls redshift, but Xsct will also do brightness. It's my goto!
Are modules available for both?
When it's simpler than RedshiftGUI and has not any more dependencies than redshift I will test it. :)
Cheers!
Yours Rava

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Redshift or other screen temp

Post#7 by rych » 27 Nov 2023, 09:30

Rava wrote:
26 Nov 2023, 20:21
Are modules available
Rava did you see this:
rych wrote:
13 Nov 2023, 09:04
Actually the only essential file in that package is the 14Kb xsct binary itself.
It's a single CLI binary one would be calling from a script for example...

petroben
Ronin
Ronin
Posts: 1
Joined: 27 Nov 2023, 17:49
Distribution: The best distribution depends

Redshift or other screen temp

Post#8 by petroben » 27 Nov 2023, 17:51

That's a clever solution! It's great to hear you found a workaround with xsct to adjust screen temperature in Porteus. Customizing your environment for those late-night sessions is key. If you have any more tips or questions, feel free to share them on the Porteus forum. Happy computing!
petroben

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Redshift or other screen temp

Post#9 by Rava » 28 Nov 2023, 01:52

I also picked xsct_1.9-1.amd64.deb from Debian 12 (Bookworm)
Created the module via deb2xzm and activated xsct_1.9-1_amd64.xzm
It gives me this when my system is in its default state running RegshiftGUI:

Code: Select all

root@rava:~# xsct
Screen 0: temperature ~ 3480 0.997068
root@rava:~# 
I presume the 3480 is set via redshift. Its ~/.redshiftgrc has this line

Code: Select all

temps=3700:3400
The "temperature ~ 3480" is only approx like the ~ suggests.

How did you insert it in your system? Activate the module at boot and have a command like

Code: Select all

xsct 4500 1.0
in your /etc/r.d/rc.local ?

Added in 10 minutes 34 seconds:
Would that work when set up for different screen temperatures via cron? One day temperature one night temperature?
But that lacks redshift's ability to determine your day and night times based on your "latlon" value in your ~/.redshiftgrc (= your latitude and longitude)

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Redshift or other screen temp

Post#10 by M. Eerie » 28 Nov 2023, 20:24

xrandr gamma parameter, allows to adjust the color temperature.

Code: Select all

xrandr --output eDP-1 --brightness 0.7 --gamma 1.0:0.95:0.85
eDP-1 being the name of my laptop's monitor, obtained by:

Code: Select all

xrandr --listactivemonitors
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Redshift or other screen temp

Post#11 by Rava » 28 Nov 2023, 20:46

Thanks M. Eerie. :)
M. Eerie wrote:
28 Nov 2023, 20:24
xrandr gamma parameter, allows to adjust the color temperature.
Or how xrandr --help|grep gamma states it:

Code: Select all

      --gamma <r>[:<g>:<b>]
rgb value, nice. How does one compute colour temperature into a rgb value?
It is all to be found in the askubuntu.com as quoted by M. Eerie

To quote a bit from there:

Code: Select all

/* cribbed from redshift, but truncated with 500K steps */
static const struct { float r; float g; float b; } whitepoints[] = {
    { 1.00000000,  0.18172716,  0.00000000, }, /* 1000K */
[…]
    { 1.00000000,  1.00000000,  1.00000000, }, /* 6500K */
[…]
    { 0.78988728,  0.86491137,  1.00000000, }, /* 10000K */
};

The three columns above are values for Red, Green and Blue.
Currently I am re-writing that table to fit the xrandr format of n.nn (with the correct rounding of values) and will post that later.

For now it seems this

Code: Select all

xrandr --output HDMI-0 --gamma 1.0:0.88:0.60
comes very close to my redshift night setting. (I set the brightness via the hardware menu on that monitor)
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Redshift or other screen temp

Post#12 by Rava » 29 Nov 2023, 00:52

After much fine adjustment (=playing around with the bytes list) I found out that this cut command gives me the non-rounded shortened version with 3 digits after the dot, including the colours temp at the end to use as template for manual rounding and inserting the : and # characters:

Code: Select all

echo "    { 1.00000000,  0.18172716,  0.00000000, }, /* 1000K */
[…]
    { 1.00000000,  1.00000000,  1.00000000, }, /* 6500K */
[…]
    { 0.78988728,  0.86491137,  1.00000000, }, /* 10000K */
[…]"|cut -b 7-11,19-24,32-37,50-
so here you go:

Colour temperature as rgb, manually rounded to 2 values after the dot, using a table from one of the answers of https://askubuntu.com/questions/1003101 ... like-usage as data source:

Code: Select all

1.00:0.18:0.00 # 1000K
1.00:0.42:0.00
1.00:0.54:0.09
1.00:0.64:0.29
1.00:0.72:0.43
1.00:0.78:0.55
1.00:0.83:0.65
1.00:0.87:0.74
1.00:0.90:0.81
1.00:0.94:0.88
1.00:0.97:0.94
1.00:1.00:1.00 # 6500K
0.95:0.97:1.00
0.91:0.94:1.00
0.88:0.92:1.00
0.85:0.91:1.00
0.83:0.89:1.00
0.81:0.88:1.00
0.79:0.86:1.00 # 10000K
0.77:0.85:1.00
Hopefully I made no errors while manually adjusting the rounding and editing the lines inserting the : and #…

For your convenience, also have the original table as taken from https://askubuntu.com/questions/1003101 ... like-usage :

Code: Select all

    { 1.00000000,  0.18172716,  0.00000000, }, /* 1000K */
    { 1.00000000,  0.42322816,  0.00000000, },
    { 1.00000000,  0.54360078,  0.08679949, },
    { 1.00000000,  0.64373109,  0.28819679, },
    { 1.00000000,  0.71976951,  0.42860152, },
    { 1.00000000,  0.77987699,  0.54642268, },
    { 1.00000000,  0.82854786,  0.64816570, },
    { 1.00000000,  0.86860704,  0.73688797, },
    { 1.00000000,  0.90198230,  0.81465502, },
    { 1.00000000,  0.93853986,  0.88130458, },
    { 1.00000000,  0.97107439,  0.94305985, },
    { 1.00000000,  1.00000000,  1.00000000, }, /* 6500K */
    { 0.95160805,  0.96983355,  1.00000000, },
    { 0.91194747,  0.94470005,  1.00000000, },
    { 0.87906581,  0.92357340,  1.00000000, },
    { 0.85139976,  0.90559011,  1.00000000, },
    { 0.82782969,  0.89011714,  1.00000000, },
    { 0.80753191,  0.87667891,  1.00000000, },
    { 0.78988728,  0.86491137,  1.00000000, }, /* 10000K */
    { 0.77442176,  0.85453121,  1.00000000, },
sans the leading and trailing C code.
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Redshift or other screen temp

Post#13 by M. Eerie » 29 Nov 2023, 13:11

Thank you for taking the time to explain it thoroughly. Sometimes I assume too much and I thought anyone would read all the answers in that thread... Specially this one in which the image is very illustrative.

There is a script in the thread that can be used to automate things, once you get your values finetuned, but I think it is a mistake to apply the same gamma values for all connected monitors, since each monitor have its own color profile and should be adjusted separately.

Anyway, that script isn't working for me. This is my approach:

Code: Select all

#!/bin/sh
night_mode() {
local MONITOR SWITCH
for MONITOR in $(xrandr | awk '/ connected/ { print $1 }'); do
case $1 in
  off) SWITCH=" --gamma 1.00:1.00:1.00 --brightness 1.0" ;; 
   on) SWITCH=" --gamma 1.00000000:0.93853986:0.88130458 --brightness 0.7" ;; ### 5500K Balanced night light temperature with 70% brightness. Change to suit your needs
    *) echo "Usage: ${0##*/} [on/off]"; exit ;;
esac
done
xrandr --output $MONITOR $SWITCH
}

night_mode on
sleep 3
night_mode off
Last edited by M. Eerie on 29 Nov 2023, 15:20, edited 2 times in total.
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Redshift or other screen temp

Post#14 by Rava » 29 Nov 2023, 13:20

^
For now I not tried the script at all since experimenting with my above table and fine adjust the settings takes up all my time that I spare for it.

And what I wrote above, that one settings matched what redshift does: for now it is the most similar I found using the xrandr --gamma r:g:b approach, but still not good enough.
But I have other things to concern about more pressing, so I might be able to do the fine tuning much later today, but most likely it will take me a few days.
Cheers!
Yours Rava

nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

Redshift or other screen temp

Post#15 by nanZor » 21 Mar 2024, 08:20

Thanks to both of you for looking into this! I just might incorporate a simple xrandr script for my needs.

And I suppose don't forget to crank it back to 6500k if you are doing any sort of image editing late at night! Easy to forget.

[Update] Much deleted. You guys have solved my problem! No need for the sct or xsct module!
That's a UNIX book - cool. -Garth

Post Reply