Minimum brightness change thresh hold
This commit is contained in:
parent
78eb04caf7
commit
acb72c3269
1 changed files with 56 additions and 29 deletions
|
@ -1,16 +1,30 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
LevelSteps=60
|
#How much light change must be seen by the sensor befor it will act
|
||||||
AnimationDelay=0.016
|
LightChange=5
|
||||||
MaxScreenBrightness=96000
|
|
||||||
|
#How often it check the sensor
|
||||||
SensorDelay=1
|
SensorDelay=1
|
||||||
|
|
||||||
|
# Scale sesor to displas brightness range
|
||||||
|
SensorToDisplayScale=24
|
||||||
|
|
||||||
|
#This should match your refesh rate other wise it will either change the back light more times than needed or too few for a smooth animation
|
||||||
|
LevelSteps=60
|
||||||
|
# The is should match the LevelSteps but in the acual time each event should take to see
|
||||||
|
AnimationDelay=0.016
|
||||||
|
|
||||||
|
|
||||||
|
# Read the variable names
|
||||||
|
MaxScreenBrightness=96000
|
||||||
|
|
||||||
MinimumBrightness=001
|
MinimumBrightness=001
|
||||||
|
|
||||||
SensorToDisplayScale=24
|
|
||||||
|
|
||||||
touch '/tmp/AB.running'
|
touch '/tmp/AB.running'
|
||||||
|
|
||||||
|
OldLight=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||||
|
|
||||||
until [ -f /tmp/AB.kill ]
|
until [ -f /tmp/AB.kill ]
|
||||||
do
|
do
|
||||||
if [[ -f /tmp/AB.stop ]]
|
if [[ -f /tmp/AB.stop ]]
|
||||||
|
@ -27,45 +41,58 @@ do
|
||||||
else
|
else
|
||||||
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||||
|
|
||||||
CurrentBrightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
MaxOld=$((OldLight + OldLight/LightChange))
|
||||||
|
MinOld=$((OldLight - OldLight/LightChange))
|
||||||
|
|
||||||
|
|
||||||
Light=$(( $Light + $MinimumBrightness ))
|
if [[ $Light -gt $MaxOld ]] || [[ $Light -lt $MinOld ]]
|
||||||
|
then
|
||||||
|
|
||||||
|
|
||||||
TempLight=$(($Light * $SensorToDisplayScale))
|
CurrentBrightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
||||||
|
|
||||||
if [[ $TempLight -gt $MaxScreenBrightness ]]
|
|
||||||
then
|
|
||||||
NewLight=$MaxScreenBrightness
|
|
||||||
else
|
|
||||||
NewLight=$TempLight
|
|
||||||
fi
|
|
||||||
|
|
||||||
DiffCount=$(( ($NewLight - $CurrentBrightness)/$LevelSteps ))
|
Light=$(( $Light + $MinimumBrightness ))
|
||||||
|
|
||||||
for i in $(eval echo {1..$LevelSteps} )
|
|
||||||
do
|
|
||||||
|
|
||||||
NewLight=$(( $DiffCount ))
|
TempLight=$(($Light * $SensorToDisplayScale))
|
||||||
|
|
||||||
if [[ $NewLight -lt 0 ]]
|
if [[ $TempLight -gt $MaxScreenBrightness ]]
|
||||||
then
|
then
|
||||||
NewLight=$( echo "$NewLight" | awk -F "-" {'print$2'})
|
NewLight=$MaxScreenBrightness
|
||||||
NewLight=$(echo $NewLight-)
|
else
|
||||||
else
|
NewLight=$TempLight
|
||||||
NewLight=$(echo +$NewLight)
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
brightnessctl -q s $NewLight
|
DiffCount=$(( ($NewLight - $CurrentBrightness)/$LevelSteps ))
|
||||||
sleep $AnimationDelay
|
|
||||||
|
|
||||||
done
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
sleep $SensorDelay
|
sleep $SensorDelay
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
rm '/tmp/AutoBright.running'
|
|
||||||
rm '/tmp/AutoBright.kill'
|
|
||||||
|
rm '/tmp/AB.running'
|
||||||
|
rm '/tmp/AB.kill'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue