Skip to content

Instantly share code, notes, and snippets.

@mrf345
Created April 3, 2018 13:10
Show Gist options
  • Save mrf345/9d52159cc75b3cfc39c424c0fc2acd8d to your computer and use it in GitHub Desktop.
Save mrf345/9d52159cc75b3cfc39c424c0fc2acd8d to your computer and use it in GitHub Desktop.
to control redshift backlight
#!/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