Created
April 3, 2018 13:10
-
-
Save mrf345/9d52159cc75b3cfc39c424c0fc2acd8d to your computer and use it in GitHub Desktop.
to control redshift backlight
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 | |
tmp_file=/tmp/redshifted | |
max_tem=7000 | |
if [ ! -f $tmp_file ];then echo $max_tem > $tmp_file ;fi | |
current_tem=$(cat $tmp_file) | |
function get_percentage () { | |
echo Redshift $(( $current_tem * 100 / $max_tem ))/100 | |
} | |
case "$1" in | |
1) | |
if [ $current_tem -lt $max_tem ] | |
then | |
tem=$(( $current_tem + 500 )) | |
redshift -O $tem > /dev/null 2>&1 | |
echo $tem > $tmp_file | |
current_tem=$tem | |
fi | |
get_percentage | |
;; | |
2) | |
if [ $current_tem -gt 2000 ] | |
then | |
tem=$(( $current_tem - 500 )) | |
redshift -O $tem > /dev/null 2>&1 | |
echo $tem > $tmp_file | |
current_tem=$tem | |
fi | |
get_percentage | |
;; | |
0) | |
redshift -x > /dev/null 2>&1 | |
echo $max_tem > $tmp_file | |
echo Diable redshift | |
;; | |
*) | |
echo Error: input error | |
echo $0 1 increase red color, 2 decrease red color, 0, disable red color | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment