Page 1 of 2

Redshift or other screen temp

Posted: 09 Nov 2023, 21:36
by nanZor
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.

Redshift or other screen temp

Posted: 13 Nov 2023, 09:04
by rych
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.

Redshift or other screen temp

Posted: 14 Nov 2023, 08:50
by nanZor
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.

Redshift or other screen temp

Posted: 26 Nov 2023, 07:33
by Rava
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.

Redshift or other screen temp

Posted: 26 Nov 2023, 20:16
by nanZor
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!

Redshift or other screen temp

Posted: 26 Nov 2023, 20:21
by Rava
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. :)

Redshift or other screen temp

Posted: 27 Nov 2023, 09:30
by rych
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...

Redshift or other screen temp

Posted: 27 Nov 2023, 17:51
by petroben
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!

Redshift or other screen temp

Posted: 28 Nov 2023, 01:52
by Rava
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)

Redshift or other screen temp

Posted: 28 Nov 2023, 20:24
by M. Eerie
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

Redshift or other screen temp

Posted: 28 Nov 2023, 20:46
by Rava
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)

Redshift or other screen temp

Posted: 29 Nov 2023, 00:52
by Rava
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.

Redshift or other screen temp

Posted: 29 Nov 2023, 13:11
by M. Eerie
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

Redshift or other screen temp

Posted: 29 Nov 2023, 13:20
by Rava
^
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.

Redshift or other screen temp

Posted: 21 Mar 2024, 08:20
by nanZor
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!