setup.sh now automatically configures your SensorToDisplayScale and writes it to AutomaticBrightness.sh
setup.sh now can update your service and script file along with restarting the service
This commit is contained in:
parent
1b0997474f
commit
7635064471
3 changed files with 49 additions and 10 deletions
43
setup.sh
43
setup.sh
|
@ -1,11 +1,46 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
case $1 in
|
||||
-u) echo "Updading Mac-like-automatic-brightness..."
|
||||
echo "Stopping AB service..."
|
||||
sudo systemctl kill AB
|
||||
echo "Updating AutomaticBrightness.sh..."
|
||||
echo "Cloning AutomaticBrighness.sh..."
|
||||
sudo cp AutomaticBrightness.sh /usr/local/bin/AutomaticBrightness.sh
|
||||
echo "Updating AB.service for systemD..."
|
||||
echo "Cloning AB.service for systemD..."
|
||||
sudo cp AB.service /etc/systemd/system/AB.service
|
||||
echo "Restarting AB service..."
|
||||
systemctl daemon-reload
|
||||
sudo systemctl start AB
|
||||
exit;;
|
||||
esac
|
||||
|
||||
echo "Setting up AutomaticBrightness.sh as a service..."
|
||||
|
||||
echo "Cloning AutomaticBrighness.sh..."
|
||||
sudo cp AutomaticBrightness.sh /usr/local/bin/
|
||||
echo "Calibrating Light Sensor Scale..."
|
||||
|
||||
echo "Cloning AB.service for systemD"
|
||||
sudo cp AB.service /etc/systemd/system/
|
||||
LSensorPath=$(find -L /sys/bus/iio/devices -maxdepth 2 -name "in_illuminance_raw" 2>/dev/null | grep "in_illuminance_raw")
|
||||
|
||||
MaxScreenBrightness=$(find -L /sys/class/backlight -maxdepth 2 -name "max_brightness" 2>/dev/null | grep "max_brightness" | xargs cat)
|
||||
|
||||
echo "Put your sensor in a bright light (outside works best)"
|
||||
read -p "Press Enter to continue..."
|
||||
|
||||
Smax=$(cat $LSensorPath)
|
||||
|
||||
Scale=$(echo "scale=2; $MaxScreenBrightness / $Smax" | bc)
|
||||
|
||||
Final="SensorToDisplayScale=$Scale"
|
||||
|
||||
awk -v new_phrase="$Final" '/SensorToDisplayScale/{ print new_phrase; next } 1' AutomaticBrightness.sh > temp && mv temp AutomaticBrightness.sh
|
||||
|
||||
|
||||
echo "Cloning AutomaticBrighness.sh..."
|
||||
sudo cp AutomaticBrightness.sh /usr/local/bin/AutomaticBrightness.sh
|
||||
|
||||
echo "Cloning AB.service for systemD..."
|
||||
sudo cp AB.service /etc/systemd/system/AB.service
|
||||
|
||||
|
||||
echo "Startin Service..."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue