Created
May 27, 2022 08:26
-
-
Save Tobiaqs/c28fef4d32999dec439e6490bae77b41 to your computer and use it in GitHub Desktop.
Manual screen dimmer for xrandr with color temperature setting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
r=255 | |
g=255 | |
b=255 | |
function apply () { | |
echo -n "Enter brightness [0, 1]: " | |
read brightness | |
while read display; do | |
r=$(printf %.6f "$((10**6 * $1/255))e-6") | |
g=$(printf %.6f "$((10**6 * $2/255))e-6") | |
b=$(printf %.6f "$((10**6 * $3/255))e-6") | |
xrandr --output $display --brightness $brightness --gamma $r:$g:$b | |
done <<< $(xrandr -q | grep " connected" | grep ^DP | awk '{print $1}') | |
} | |
select option in Default "1900K Candle" "2600K 40W Tungsten" "2850K 100W Tungsten" "3200K Halogen" "5200K Carbon Arc" "5400K High Noon" "6000K Direct Sun" "7000K Overcast Sky" "20000K Clear Blue Sky"; | |
do | |
case "$option" in | |
Default) | |
apply 255 255 255 | |
break | |
;; | |
1900K*) | |
apply 255 147 41 | |
break | |
;; | |
2600K*) | |
apply 255 197 143 | |
break | |
;; | |
2850K*) | |
apply 255 214 170 | |
break | |
;; | |
3200K*) | |
apply 255 241 224 | |
break | |
;; | |
5200K*) | |
apply 255 250 244 | |
break | |
;; | |
5400K*) | |
apply 255 255 251 | |
break | |
;; | |
6000K*) | |
apply 255 255 255 | |
break | |
;; | |
7000K*) | |
apply 201 226 255 | |
break | |
;; | |
20000K*) | |
apply 64 156 255 | |
break | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment