1
0
Fork 0
mirror of https://github.com/Horhik/dotfiles.git synced 2024-11-27 10:31:30 +00:00
Dotfiles/.config/polybar/scripts/redshift/redshift.sh
2020-07-27 07:59:00 +03:00

49 lines
909 B
Bash
Executable file

#!/bin/sh
envFile=~/.config/polybar/scripts/redshift/env.sh
changeValue=300
changeMode() {
sed -i "s/REDSHIFT=$1/REDSHIFT=$2/g" $envFile
REDSHIFT=$2
echo $REDSHIFT
}
changeTemp() {
if [ "$2" -gt 1000 ] && [ "$2" -lt 25000 ]
then
sed -i "s/REDSHIFT_TEMP=$1/REDSHIFT_TEMP=$2/g" $envFile
redshift -x
redshift -O $((REDSHIFT_TEMP+changeValue))
fi
}
case $1 in
toggle)
if [ "$REDSHIFT" = on ];
then
changeMode "$REDSHIFT" off
redshift -x
else
changeMode "$REDSHIFT" on
redshift -O "$REDSHIFT_TEMP"
fi
;;
increase)
changeTemp $((REDSHIFT_TEMP)) $((REDSHIFT_TEMP+changeValue))
;;
decrease)
changeTemp $((REDSHIFT_TEMP)) $((REDSHIFT_TEMP-changeValue));
;;
temperature)
case $REDSHIFT in
on)
printf "%dK " "$REDSHIFT_TEMP"
;;
off)
printf "off "
;;
esac
;;
esac