Minor performance improvments
This commit is contained in:
parent
a9d2623851
commit
e6807f6dce
2 changed files with 13 additions and 28 deletions
40
AutomaticBrightness.sh
Normal file → Executable file
40
AutomaticBrightness.sh
Normal file → Executable file
|
@ -34,14 +34,17 @@ do
|
||||||
num=${OPTARG};;
|
num=${OPTARG};;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
if [[ -f /tmp/AB.offset ]]
|
|
||||||
|
if [[ -f /dev/shm/AB.offset ]]
|
||||||
then
|
then
|
||||||
OffSet=$(cat /tmp/AB.offset)
|
OffSet=$(cat /dev/shm/AB.offset)
|
||||||
else
|
else
|
||||||
OffSet=0
|
OffSet=0
|
||||||
$(echo $OffSet > /tmp/AB.offset)
|
$(echo $OffSet > /dev/shm/AB.offset)
|
||||||
|
$(chmod 666 /dev/shm/AB.offset)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
OffSet=$((OffSet < 0 ? 0 : OffSet))
|
OffSet=$((OffSet < 0 ? 0 : OffSet))
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +59,7 @@ then
|
||||||
|
|
||||||
OffSet=$((OffSet < 0 ? 0 : OffSet))
|
OffSet=$((OffSet < 0 ? 0 : OffSet))
|
||||||
|
|
||||||
$(echo $OffSet > /tmp/AB.offset)
|
$(echo $OffSet > /dev/shm/AB.offset)
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
||||||
|
@ -70,31 +73,18 @@ renice "$priority" "$$"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
touch '/tmp/AB.running'
|
|
||||||
|
|
||||||
OldLight=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
OldLight=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||||
|
|
||||||
until [ -f /tmp/AB.kill ]
|
while true
|
||||||
do
|
do
|
||||||
if [[ -f /tmp/AB.stop ]]
|
if [[ -f /dev/shm/AB.offset ]]
|
||||||
then
|
then
|
||||||
rm '/tmp/AB.stop'
|
OffSet=$(cat /dev/shm/AB.offset)
|
||||||
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 ]]
|
|
||||||
then
|
|
||||||
OffSet=$(cat /tmp/AB.offset)
|
|
||||||
else
|
else
|
||||||
OffSet=0
|
OffSet=0
|
||||||
$(echo $OffSet > /tmp/AB.offset)
|
$(echo $OffSet > /dev/shm/AB.offset)
|
||||||
|
$(chmod 666 /dev/shm/AB.offset)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
Light=$(cat /sys/bus/iio/devices/iio\:device0/in_illuminance_raw)
|
||||||
|
@ -152,13 +142,7 @@ do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep $SensorDelay
|
sleep $SensorDelay
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
rm '/tmp/AB.running'
|
|
||||||
rm '/tmp/AB.kill'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
setup.sh
1
setup.sh
|
@ -7,6 +7,7 @@ sudo cp AutomaticBrightness.sh /usr/local/bin/
|
||||||
echo "Cloning AB.service for systemD"
|
echo "Cloning AB.service for systemD"
|
||||||
sudo cp AB.service /etc/systemd/system/
|
sudo cp AB.service /etc/systemd/system/
|
||||||
|
|
||||||
|
|
||||||
echo "Startin Service..."
|
echo "Startin Service..."
|
||||||
sudo systemctl enable AB
|
sudo systemctl enable AB
|
||||||
sudo systemctl start AB
|
sudo systemctl start AB
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue