diff --git a/AutomaticBrightness.sh b/AutomaticBrightness.sh old mode 100644 new mode 100755 index a716c8f..4462c2c --- a/AutomaticBrightness.sh +++ b/AutomaticBrightness.sh @@ -34,14 +34,17 @@ do num=${OPTARG};; esac done -if [[ -f /tmp/AB.offset ]] + +if [[ -f /dev/shm/AB.offset ]] then - OffSet=$(cat /tmp/AB.offset) + OffSet=$(cat /dev/shm/AB.offset) else OffSet=0 - $(echo $OffSet > /tmp/AB.offset) + $(echo $OffSet > /dev/shm/AB.offset) + $(chmod 666 /dev/shm/AB.offset) fi + OffSet=$((OffSet < 0 ? 0 : OffSet)) @@ -56,7 +59,7 @@ then OffSet=$((OffSet < 0 ? 0 : OffSet)) - $(echo $OffSet > /tmp/AB.offset) + $(echo $OffSet > /dev/shm/AB.offset) exit @@ -70,31 +73,18 @@ renice "$priority" "$$" -touch '/tmp/AB.running' OldLight=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw) -until [ -f /tmp/AB.kill ] +while true 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 - - if [[ -f /tmp/AB.offset ]] + if [[ -f /dev/shm/AB.offset ]] then - OffSet=$(cat /tmp/AB.offset) + OffSet=$(cat /dev/shm/AB.offset) else OffSet=0 - $(echo $OffSet > /tmp/AB.offset) + $(echo $OffSet > /dev/shm/AB.offset) + $(chmod 666 /dev/shm/AB.offset) fi Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw) @@ -152,13 +142,7 @@ do fi sleep $SensorDelay - fi - done -rm '/tmp/AB.running' -rm '/tmp/AB.kill' - - diff --git a/setup.sh b/setup.sh index ab8ab0c..8689d3c 100755 --- a/setup.sh +++ b/setup.sh @@ -7,6 +7,7 @@ sudo cp AutomaticBrightness.sh /usr/local/bin/ echo "Cloning AB.service for systemD" sudo cp AB.service /etc/systemd/system/ + echo "Startin Service..." sudo systemctl enable AB sudo systemctl start AB