Stop,Start,Kill
Now you can Stop, Start or even Kill the script by simply putting a file in /tmp
This commit is contained in:
parent
56d82d35d2
commit
bdd782d69d
1 changed files with 51 additions and 34 deletions
|
@ -9,44 +9,61 @@ MinimumBrightness=001
|
||||||
|
|
||||||
SensorToDisplayScale=24
|
SensorToDisplayScale=24
|
||||||
|
|
||||||
while true; do
|
touch '/tmp/AB.running'
|
||||||
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
|
||||||
|
|
||||||
CurrentBrightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
until [ -f /tmp/AB.kill ]
|
||||||
|
|
||||||
|
|
||||||
Light=$(( $Light + $MinimumBrightness ))
|
|
||||||
|
|
||||||
|
|
||||||
TempLight=$(($Light * $SensorToDisplayScale))
|
|
||||||
|
|
||||||
if [[ $TempLight -gt $MaxScreenBrightness ]]
|
|
||||||
then
|
|
||||||
NewLight=$MaxScreenBrightness
|
|
||||||
else
|
|
||||||
NewLight=$TempLight
|
|
||||||
fi
|
|
||||||
|
|
||||||
DiffCount=$(( ($NewLight - $CurrentBrightness)/$LevelSteps ))
|
|
||||||
|
|
||||||
for i in $(eval echo {1..$LevelSteps} )
|
|
||||||
do
|
do
|
||||||
|
if [[ -f /tmp/AB.stop ]]
|
||||||
NewLight=$(( $DiffCount ))
|
|
||||||
|
|
||||||
if [[ $NewLight -lt 0 ]]
|
|
||||||
then
|
then
|
||||||
NewLight=$( echo "$NewLight" | awk -F "-" {'print$2'})
|
rm '/tmp/AB.stop'
|
||||||
NewLight=$(echo $NewLight-)
|
rm '/tmp/AB.running'
|
||||||
|
|
||||||
|
until [[ -f /tmp/AB.start ]]
|
||||||
|
do
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
rm '/tmp/AB.start'
|
||||||
|
touch '/tmp/AB.running'
|
||||||
else
|
else
|
||||||
NewLight=$(echo +$NewLight)
|
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||||
fi
|
|
||||||
|
|
||||||
brightnessctl -q s $NewLight
|
CurrentBrightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
||||||
sleep $AnimationDelay
|
|
||||||
|
|
||||||
done
|
Light=$(( $Light + $MinimumBrightness ))
|
||||||
|
|
||||||
sleep $SensorDelay
|
|
||||||
|
TempLight=$(($Light * $SensorToDisplayScale))
|
||||||
|
|
||||||
|
if [[ $TempLight -gt $MaxScreenBrightness ]]
|
||||||
|
then
|
||||||
|
NewLight=$MaxScreenBrightness
|
||||||
|
else
|
||||||
|
NewLight=$TempLight
|
||||||
|
fi
|
||||||
|
|
||||||
|
DiffCount=$(( ($NewLight - $CurrentBrightness)/$LevelSteps ))
|
||||||
|
|
||||||
|
for i in $(eval echo {1..$LevelSteps} )
|
||||||
|
do
|
||||||
|
|
||||||
|
NewLight=$(( $DiffCount ))
|
||||||
|
|
||||||
|
if [[ $NewLight -lt 0 ]]
|
||||||
|
then
|
||||||
|
NewLight=$( echo "$NewLight" | awk -F "-" {'print$2'})
|
||||||
|
NewLight=$(echo $NewLight-)
|
||||||
|
else
|
||||||
|
NewLight=$(echo +$NewLight)
|
||||||
|
fi
|
||||||
|
|
||||||
|
brightnessctl -q s $NewLight
|
||||||
|
sleep $AnimationDelay
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
sleep $SensorDelay
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
rm '/tmp/AutoBright.kill'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue