From 7feec2dc38d7fbd15324144c896b8195a7941789 Mon Sep 17 00:00:00 2001 From: steel99xl Date: Sat, 7 Oct 2023 14:14:40 -0400 Subject: [PATCH] New Controls --- AutomaticBrightness.sh | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/AutomaticBrightness.sh b/AutomaticBrightness.sh index f2f86a8..aab7dd3 100644 --- a/AutomaticBrightness.sh +++ b/AutomaticBrightness.sh @@ -21,6 +21,55 @@ MaxScreenBrightness=96000 MinimumBrightness=001 + +# 2 : Default | 1 : Add Offset | 0 : Subtract Offset, Recomended not to change +op=2 + +while getopts i:d: flag +do + case "${flag}" in + i) op=1 + num=${OPTARG};; + d) op=0 + num=${OPTARG};; + esac +done +if [[ -f /tmp/AB.offset ]] +then + OffSet=$(cat /tmp/AB.offset) +else + OffSet=0 + $(echo $OffSet > /tmp/AB.offset) +fi + + +if [[ $OffSet -lt 0 ]] +then + OffSet=0 +fi + + +if [[ $op -lt 2 ]] +then + if [[ $op -eq 1 ]] + then + OffSet=$((OffSet + num)) + else + OffSet=$((OffSet - num)) + fi + + if [[ $OffSet -lt 0 ]] + then + OffSet=0 + fi + + $(echo $OffSet > /tmp/AB.offset) + + exit + +fi + + touch '/tmp/AB.running' OldLight=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw) @@ -39,7 +88,17 @@ do rm '/tmp/AB.start' touch '/tmp/AB.running' else + + if [[ -f /tmp/AB.offset ]] + then + OffSet=$(cat /tmp/AB.offset) + else + OffSet=0 + $(echo $OffSet > /tmp/AB.offset) + fi + Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw) + Light=$((Light + OffSet)) if [[ $Light -lt $LightChange ]] then