Alternative to redshift

Hi.
I am on a new AL-install now (installed yesterday).
Stable and easy install. Works great!!

I have used redshift for years now and last time I installed I had problems getting it to work. This time and can not get it to work, even manual. Instead I found an app called stcd that i am trying now. It’s very minimal and no conf-file.

Are all of you guys still using redshift?

womp

1 Like

While not using AL right now, I still do use RedShift on all my Linux systems (AL, Arch and Debian). No issues here.

1 Like

Wayland + wlsunset.

3 Likes

I use a small C program for X and a script to call it.

/* gcc sct.c -o sct -lm -lX11 -lXrandr */
/* or */
/* cc -std=c99 -O2 -I /usr/X11R6/include -o sct sct.c -L /usr/X11R6/lib -lm -lX11 -lXrandr */

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xproto.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/Xrender.h>
#include <strings.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdarg.h>
#include <math.h>

/* 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,  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, },
};

int main(int argc, char **argv)
{
	Display *dpy = XOpenDisplay(NULL);
	int screen = DefaultScreen(dpy);
	Window root = RootWindow(dpy, screen);

	XRRScreenResources *res = XRRGetScreenResourcesCurrent(dpy, root);

	int temp = 6500;
	if (argc > 1)
		temp = atoi(argv[1]);
	if (temp < 1000 || temp > 10000)
		temp = 6500;

	temp -= 1000;
	double ratio = temp % 500 / 500.0;
#define AVG(c) whitepoints[temp / 500].c * (1 - ratio) + whitepoints[temp / 500 + 1].c * ratio
	double gammar = AVG(r);
	double gammag = AVG(g);
	double gammab = AVG(b);
	int num_crtcs = res->ncrtc;

	for (int c = 0; c < res->ncrtc; c++) {
		int crtcxid = res->crtcs[c];
		XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(dpy, res, crtcxid);
		int size = XRRGetCrtcGammaSize(dpy, crtcxid);
		XRRCrtcGamma *crtc_gamma = XRRAllocGamma(size);
		for (int i = 0; i < size; i++) {
			double g = 65535.0 * i / size;
			crtc_gamma->red[i] = g * gammar;
			crtc_gamma->green[i] = g * gammag;
			crtc_gamma->blue[i] = g * gammab;
		}
		XRRSetCrtcGamma(dpy, crtcxid, crtc_gamma);
		XFree(crtc_gamma);
	}
}
#!/bin/bash

# change monitor colour temperature using sct and a simple loop

# map hours of the day to a colour temperature
hours=(
4500 4500 4500 4500 4500 4500 5000 5500  # 0-7
6000 6000 6000 6000 6000 6000 6000 6000  # 8-15
6000 6000 6000 6000 5500 5000 4500 4500  # 16-23
)

if pgrep "$0" >/dev/null 2>&1; then
	echo "another instance is already running" >&2
	exit
fi

while :; do
	sct "${hours[$(date '+%H')]}"
	sleep 600 # 10 min
done

Then you just run the script in your startup somewhere and background it

/path/to/script &
8 Likes

@nate that’s awesome

2 Likes

After some “fiddlin” I managed to make redshift work! I thank you all for answers and suggestions!
I will go with redshift for now.

womp