-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnight_mode
executable file
·50 lines (48 loc) · 1.97 KB
/
night_mode
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
#!/bin/sh
# Taken from https://blog.onetwentyseven001.com/more-of-xrandr-or-blue-light-exposure/#.W2ExkRRKjb1
night_mode() {
for disp in $(xrandr | sed -n 's/^\([^ ]*\)[ ]*connected.*/\1/p'); do
xrandr --output $disp --gamma $1 --brightness $2
done }
case $1 in
day) night_mode 1:1:1 1.0 ;;
normal) night_mode 1:1:1 1.0 ;;
night) night_mode 1:0.78:0.55 1.0 ;;
1000) night_mode 1:0.18:0.0 1.0 ;;
1500) night_mode 1:0.42:0.0 1.0 ;;
2000) night_mode 1:0.54:0.09 1.0 ;;
2500) night_mode 1:0.64:0.28 1.0 ;;
3000) night_mode 1:0.72:0.43 1.0 ;;
3500) night_mode 1:0.78:0.55 1.0 ;;
4000) night_mode 1:0.83:0.65 1.0 ;;
4500) night_mode 1:0.87:0.74 1.0 ;;
5000) night_mode 1:0.90:0.81 1.0 ;;
5500) night_mode 1:0.94:0.88 1.0 ;;
6000) night_mode 1:0.97:0.94 1.0 ;;
6500) night_mode 1:1:1 1.0 ;;
*) night_mode 1:1:1 1.0 ;;
esac
# From sct code:
#/* 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, },
#};