
Sct – set color temperature - ingve
http://www.tedunangst.com/flak/post/sct-set-color-temperature
======
rogerbinns
Note that the dependencies aren't because of setting the colour temperature,
but to get your location information (see geoclue in the list). geoclue has
several providers, but a common one for desktop machines is to connect to a
network service that does geoip. Consequently most of the dependencies arrive
due to that (eg proxies, crypto, glue code for object models to do all that,
and some innocent bystanders).

The location information is used so that redshift can alter the colour
temperature during the day (less needed) and dusk, evening and night (very
needed).

~~~
cvwright
Wait, what? Why does it need to know location? If you want to know what time
it is, why not just call localtime()?

~~~
rogerbinns
Because it uses sunset times to change your colour temperature around dusk.
Localtime is not sufficient to work out dusk with any degree of accuracy.

Those of us using Redshift are not doing so for a one off colour temperature
set, but because it is continually updated through the day and night.

You can tell it your location manually or have it done automatically.

Redshift is open source. It does not have binary blobs, patents, a business
model and similar crud that f.lux does. Adjust your paranoia/expectations as
needed.

~~~
semi-extrinsic
This location-based setting sounds clever, but it's a crappy idea if you live
further north than ~60°N. Or do you want your screen to go red at 3pm and stay
that way until 10am the next day when it's winter? And then in summer it's red
from 2am to 4am?

I use CF.lumen on Android and Redshift on Linux and I have to regularly shift
the fake locations I give them in order to have them do what I want. At least
with Redshift on Linux I can script it...

~~~
spantaleev
Self-plug for something I wrote some time ago - you can use redshift-scheduler
( [https://github.com/spantaleev/redshift-
scheduler/](https://github.com/spantaleev/redshift-scheduler/) ) to set up a
custom schedule (ultimately using redshift to set the screen temperature).

~~~
semi-extrinsic
Ah, with an Arch package and everything! Will install, thanks!

------
hrjet
You can do it with a couple of lines of shell script too, using the xcalib
utility:

[https://gist.github.com/hrj/e9ed0d73d2daaa98b2d2](https://gist.github.com/hrj/e9ed0d73d2daaa98b2d2)

Been using that for more than an year with great results.

I also have another version of it:
[https://gist.github.com/hrj/6561271](https://gist.github.com/hrj/6561271)

(this version cuts the green and blue equally)

------
taneliv
Cool! Or, warm depending on parameter.

On Ubuntu includes are apparently broken, complaining about strings.h included
from Xlibint.h ...

There's probably a yak to shave in that. However, if you're lazy and hit the
same problem, you can compile a functional sct by lifting declarations of i
and c outside their loops and dropping "-std=c99" from the command line.

~~~
protopete
I was able to compile it on Ubuntu after moving the X11 includes to the bottom
of the list:

    
    
      #include <stdio.h>
      #include <strings.h>
      #include <string.h>
      #include <stdlib.h>
      #include <stdint.h>
      #include <inttypes.h>
      #include <stdarg.h>
      #include <math.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>

~~~
hiimnate
I also had to do some fiddling with the includes (removing the `strings.h`
include got it working for me. Why is this required?

~~~
ploxiln
Historically, including some headers ended up including some other headers
automatically, such that the author might not realize what headers the file
depends on, because it compiles without them explicitly included. glibc (and
maybe gcc and xlib?) have been cleaning this up where possible, slowly over
time. So a file that had "correct enough" includes for an older glibc might
now be caught not including a header it needed all along.

Or maybe it's a similar situation but actually related to "feature test
macros" (see
[https://lwn.net/Articles/590381/](https://lwn.net/Articles/590381/))

------
mindslight
I've been thinking of using xcalib to invert my display colors to reclaim a
sane black background.

My terminal/editor have always been dark background, but eventually I had
enough of the web's blinding conventions [0], and installed a browser
extension. But it doesn't work as well as it should and I'm thinking a blanket
inversion would be preferable.

It seems like xcalib (and associated machinery) only supports a simple RGB LUT
though, which means green turns to purple etc. It's unfortunate that it
doesn't have the universal approach of LUT->matrix->LUT like a calibratable
monitor, so the invert could be done in say HSV space.

[0] White paper makes sense because it's a _reflective_ medium that relies on
ambient light. A glaring white background is the wrong choice for an emissive
display. Notice how visual art applications (photoshop, maya, etc) default to
a grey background and dark color scheme.

------
pja
The redshift binary can be built without any of the GUI stuff at all, so some
of the bloat complaint is a bit over-blown - more a fault of the port provider
to not offer the option of a stripped down install perhaps?

------
striking
Thank you for your work! It amazes me sometimes how simple such powerful tools
can become.

> You start by getting information for each Canadian Radio-television and
> Telecommunications Commission (CRTC)

wait, hold on a minute

~~~
howeyc
Not sure if Ted is Canadian, but it's a joke.

Mention the letters to CRTC to any Canadian and that's what they think about.

The letters CRTC are in some of the function calls.

~~~
grapeshot
It's for CRT Controller (probably after the Motorola 6845 CRTC chip that was
in the original PC)

~~~
gpvos
Well, maybe the documentation for the function could have mentioned that. Oh
no, there was none.

------
hammerandtongs
Thanks for this.

Over the years I've decided the gradual adjustment lat/long bits are really a
negative feature. It engineer cool but it's counterproductive to the goal.

I want the monitor dim between 7pm and 630am regardless of time of year so I
cronned that into redshift.

Your body clock probably wants the full blue light in the am fwiw.

I'll give sct a try to see if its more pleasing to the eye.

------
specialist
Another potential use case: improved accessibility to mitigate color
deficiency.

"Help us Test the Adjustments for Color Deficiency"

[http://blog.jetbrains.com/idea/2015/09/intellij-
idea-15-eap-...](http://blog.jetbrains.com/idea/2015/09/intellij-idea-15-eap-
help-us-test-the-adjustments-for-color-deficiency/)

I was delighted to see this feature. One of those facepalm moments that
quickly transitions from "neat!" to "why didn't I think of that?"

Having an OS level system wide setting might be useful.

[https://en.wikipedia.org/wiki/Color_blindness](https://en.wikipedia.org/wiki/Color_blindness)

------
nicholasbishop
I wrote a small Python utility recently that provides a minimal interface for
brightness and temperature: [https://github.com/nicholasbishop/xrandr-
slightly-fewer-tear...](https://github.com/nicholasbishop/xrandr-slightly-
fewer-tears)

It doesn't do anything fancy with geolocation, I tend to just tweak the
sliders every now and then depending on what my eyes tell me :)

------
methyl
Does it support changing temperature gradually when it's starting to get dark
outside? This is one of biggest features of f-lux and redshift I believe.

~~~
plorg
If you have redshift installed but want to use this instead of xrandr to
change color temperature you could run the following as a script:

    
    
        redshift -m dummy | while read line;do sct "${line/Temperature: /}";done

------
halosghost
This is a nice little idea; I’m cleaning it up for my own use under Linux, and
I’d like to release it, but I cannot seem to find a license declaration for
Ted’s code.

Anyone happen to know what license it was released under?

~~~
0xfaf0
I asked Ted, if I was able to upload my version to Github and he allowed me to
do whatever I wanted to do with it.

Here it is: [https://github.com/faf0/sct](https://github.com/faf0/sct)

Compiles on Ubuntu 14.04.

------
anon4
Cool, but is there any way we can do this without sacrificing colour
precision? Also, the author didn't say if the values in the array are in
linear or sRGB colour-space, though I'd bet it's the latter.

~~~
SCdF
Maybe I don't get what you mean, but how could you? These utilities are taking
your full 24bit colour palette and intentionally removing some colours.

~~~
anon4
Don't monitors have colour calibration settings that can be set
programatically? So you can change the output light intensity that corresponds
to each of 0-255, i.e. change the voltage applied to the crystal at each of
them?

