From cc13862a9c0c8e1fe3df2ff9a88f73874452c8af Mon Sep 17 00:00:00 2001 From: steel99xl Date: Sat, 24 Sep 2022 13:50:50 -0400 Subject: [PATCH] Add files via upload --- AutomaticBrightness.sh | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 AutomaticBrightness.sh diff --git a/AutomaticBrightness.sh b/AutomaticBrightness.sh new file mode 100644 index 0000000..9d0e4b0 --- /dev/null +++ b/AutomaticBrightness.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +LevelSteps=60 +AnimationDelay=0.016 +MaxScreenBrightness=96000 +SensorDelay=1 + +MinimumBrightness=001 + +SensorToDisplayScale=24 + +while true; do +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 )) + + 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 + +done