mirror of
https://github.com/Horhik/dotfiles.git
synced 2024-11-12 19:54:16 +00:00
49 lines
909 B
Bash
Executable file
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
|