About
Xsct (X11 set color temperature) is a UNIX tool which allows you to set the color temperature of your screen. It is simpler than Redshift and f.lux.
Original code was published by Ted Unangst in the public domain: https://www.tedunangst.com/flak/post/sct-set-color-temperature
Minor modifications were made in order to get sct to:
- compile on Ubuntu 14.04 and later releases
- iterate over all screens of the default display and change the color temperature
- free the Display structure
- fix memleaks
- clean up code
- return
EXIT_SUCCESS
Installation
Make-based
On UNIX-based systems, a convenient method of building this software is using Make.
Since the Makefile
is simple and portable, both the BSD and GNU make variants will have no problems parsing and executing it correctly.
The simplest invocation is
make
that will use the default values for all flags as provided in the Makefile
.
Overriding any of the following variables is supported by exporting a variable with the same name and your desired content to the environment:
CC
CFLAGS
LDFLAGS
PREFIX
BIN
(the directory into which the resulting binary will be installed)MAN
(the directory into which the man page will be installed)INSTALL
(install(1)
program used to create directories and copy files)
Both example calls are equivalent and will build the software with the specified compiler and custom compiler flags:
make CC='clang' CFLAGS='-O2 -pipe -g3 -ggdb3' LDFLAGS='-L/very/special/directory -flto'
export CC='clang'
export CFLAGS='-O2 -pipe -g3 -ggdb3'
export LDFLAGS='-L/very/special/directory -flto'
make
The software can be installed by running the following command:
make install
If you prefer a different installation location, override the PREFIX
variable:
make install PREFIX="${HOME}/xsct-prefix"
export PREFIX="${HOME}/xsct-prefix"
make install
Manual compilation
Compile the code using the following command:
gcc -Wall -Wextra -Werror -pedantic -std=c99 -O2 -I /usr/X11R6/include xsct.c -o xsct -L /usr/X11R6/lib -lX11 -lXrandr -lm -s
Usage
Provided that xsct binary is located in your $PATH
, execute it using the following command:
xsct 3700 0.9
The first parameter (3700
above) represents the color temperature.
The second parameter (0.9
above) represents the brightness. The values are in the range [0.0, 1.0]
.
If xsct
is called with parameter 0, the color temperature is set to 6500
.
If xsct
is called with the color temperature parameter only, the brightness is set to 1.0
.
If xsct
is called without parameters, the current display temperature and brightness are estimated.
The following options, which can be specified before the optional temperature parameter, are supported:
-h
,--help
: display the help page-v
,--verbose
: display debugging information-d <delta>
,--delta <delta>
: shift temperature by the temperature value-s <screen>
,--screen <screen>
N
: use the screen specified by given zero-based index-t
,--toggle
: toggle between night and day temperature-c <crtc>
,--crtc <crtc>
N
: use the CRTC specified by given zero-based index
Test xsct using the following command:
xsct 3700 0.9 && xsct
Resources
The following website by Mitchell Charity provides a table for the conversion between black-body temperatures and color pixel values: http://www.vendian.org/mncharity/dir3/blackbody/