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,28 +9,43 @@ MinimumBrightness=001
|
|||
|
||||
SensorToDisplayScale=24
|
||||
|
||||
while true; do
|
||||
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||
touch '/tmp/AB.running'
|
||||
|
||||
CurrentBrightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
||||
|
||||
|
||||
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} )
|
||||
until [ -f /tmp/AB.kill ]
|
||||
do
|
||||
if [[ -f /tmp/AB.stop ]]
|
||||
then
|
||||
rm '/tmp/AB.stop'
|
||||
rm '/tmp/AB.running'
|
||||
|
||||
until [[ -f /tmp/AB.start ]]
|
||||
do
|
||||
sleep 10
|
||||
done
|
||||
rm '/tmp/AB.start'
|
||||
touch '/tmp/AB.running'
|
||||
else
|
||||
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||
|
||||
CurrentBrightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
||||
|
||||
|
||||
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
|
||||
|
||||
NewLight=$(( $DiffCount ))
|
||||
|
||||
|
@ -45,8 +60,10 @@ do
|
|||
brightnessctl -q s $NewLight
|
||||
sleep $AnimationDelay
|
||||
|
||||
done
|
||||
done
|
||||
|
||||
sleep $SensorDelay
|
||||
sleep $SensorDelay
|
||||
fi
|
||||
|
||||
done
|
||||
rm '/tmp/AutoBright.kill'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue