File: README.md

package info (click to toggle)
xsct 2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 112 kB
  • sloc: ansic: 332; makefile: 29
file content (135 lines) | stat: -rw-r--r-- 5,502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
![GitHub release (latest by date)](https://img.shields.io/github/v/release/faf0/sct)
![GitHub Release Date](https://img.shields.io/github/release-date/faf0/sct)
![GitHub repo size](https://img.shields.io/github/repo-size/faf0/sct)
![GitHub](https://img.shields.io/github/license/faf0/sct)  

# 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](https://github.com/jonls/redshift) and [f.lux](https://justgetflux.com/).

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](https://www.gnu.org/software/make/) variants will have no problems parsing and executing it correctly.

The simplest invocation is
~~~sh
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:
~~~sh
make CC='clang' CFLAGS='-O2 -pipe -g3 -ggdb3' LDFLAGS='-L/very/special/directory -flto'
~~~

~~~sh
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:
~~~sh
make install
~~~

If you prefer a different installation location, override the `PREFIX` variable:
~~~sh
make install PREFIX="${HOME}/xsct-prefix"
~~~

~~~sh
export PREFIX="${HOME}/xsct-prefix"
make install
~~~

## Manual compilation

Compile the code using the following command:
~~~sh
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:
~~~sh
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>`: temperature and brightness are shifted relatively and not absolutely
- `-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

Here are a few examples of how to control the brightness and the temperature using `xsct`:

| Command             | Explanation                                                             |
|---------------------|-------------------------------------------------------------------------|
| `xsct`              | Estimate the current display temperature and brightness                 |
| `xsct 0`            | Set the temperature to `6500` and the brightness to `1.0` (default)     |
| `xsct 3700 0.9`     | Set the temperature to `3700` and the brightness to `0.9`               |
| `xsct 3700`         | Set the temperature to `3700` and the brightness to `1.0` (default)     |
| `xsct -d 1000`      | Increase the temperature by `1000`                                      |
| `xsct -d -500`      | Decrease the temperature by `500`                                       |
| `xsct -d 1000 0.2`  | Increase the temperature by `1000` and increase the brightness by `0.2` |
| `xsct -d -500 -0.3` | Decrease the temperature by `500` and decrease the brightness by `0.3`  |
| `xsct -d 0 0.2`     | Increase the brightness by `0.2`                                        |

Test xsct using the following command:
~~~sh
xsct 3700 0.9 && xsct
~~~

# Quirks

If the delta mode is used to decrease the brightness to below 0.0 and then increased above 0.0, the temperature will reset to 6500 K, regardless of whatever it was before the brightness reached 0.
This is because the temperature is reset to 0 K when the brightness is set equal to or below 0.0 (to verify this, you can run `xsct 0 0.0; 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/

---

https://github.com/faf0/sct/