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
|
@ -1,5 +1,5 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Mac like automatic brightness as service
|
Description=Mac-like-automatic-brightness as service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|
14
README.md
14
README.md
|
@ -1,7 +1,7 @@
|
||||||
# Mac-like-automatic-brightness
|
# Mac-like-automatic-brightness
|
||||||
A simple script to provide a "Mac" like automatic brightness adjustemnt/ animation.
|
A simple script to provide a "Mac" like automatic brightness adjustemnt/ animation.
|
||||||
## Now as a system service
|
## Now as a system service
|
||||||
Run ```setup.sh``` to make it a service
|
Run ```setup.sh``` to make it a service and automaticaly set your ```SensorToDisplacScale```
|
||||||
|
|
||||||
made for the FrameWork laptop
|
made for the FrameWork laptop
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ Your sensor has a diffrent range thant the 12th Gen Intel Framework laptop senso
|
||||||
|
|
||||||
```/dev/shm/AB.offset | Stores current offset for the sensor```
|
```/dev/shm/AB.offset | Stores current offset for the sensor```
|
||||||
|
|
||||||
|
* Changing the offset of your backlight while the service is running is one way you increase or decease your screen bightness but keep the automatic adjustments when the lighting changes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Configuring
|
## Configuring
|
||||||
|
@ -41,14 +43,16 @@ Your sensor has a diffrent range thant the 12th Gen Intel Framework laptop senso
|
||||||
|
|
||||||
```LevelSteps``` Sets amount of brightness steps, recomended to match refeshrate
|
```LevelSteps``` Sets amount of brightness steps, recomended to match refeshrate
|
||||||
|
|
||||||
```AnimationDelay``` Speed of the brightness animation(delay between each step), recomended screen refreshrate in seconds
|
```AnimationDelay``` Speed of the brightness animation(delay between each step), recomended screen refreshrate in seconds (0.16 of 60Hz)
|
||||||
|
|
||||||
```MaxScreenBrightness``` The highest value your screen supports, check ```/sys/class/backlight/intel_backlight/max_brightness``` on framework laptops
|
|
||||||
|
|
||||||
```MinimunBrightness``` The minimum screen brightness, recomended minumim 001 so the backlight dosn't turn off
|
```MinimunBrightness``` The minimum screen brightness, recomended minumim 001 so the backlight dosn't turn off
|
||||||
|
|
||||||
~~ Other things to note
|
### Run``` setup.sh -u``` to update the installed script and service
|
||||||
|
|
||||||
|
~~ Other things to note but shouldn't have to adjust
|
||||||
|
|
||||||
```Light``` The file where your lightsensor has its current value
|
```Light``` The file where your lightsensor has its current value
|
||||||
|
|
||||||
```CurrentBirghtness``` The file where your screen stores its current brightness
|
```CurrentBirghtness``` The file where your screen stores its current brightness
|
||||||
|
|
||||||
|
```MaxScreenBrightness``` The highest value your screen supports, check ```/sys/class/backlight/intel_backlight/max_brightness``` on framework laptops
|
||||||
|
|
43
setup.sh
43
setup.sh
|
@ -1,11 +1,46 @@
|
||||||
#!/bin/bash
|
#!/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 "Setting up AutomaticBrightness.sh as a service..."
|
||||||
|
|
||||||
echo "Cloning AutomaticBrighness.sh..."
|
echo "Calibrating Light Sensor Scale..."
|
||||||
sudo cp AutomaticBrightness.sh /usr/local/bin/
|
|
||||||
|
|
||||||
echo "Cloning AB.service for systemD"
|
LSensorPath=$(find -L /sys/bus/iio/devices -maxdepth 2 -name "in_illuminance_raw" 2>/dev/null | grep "in_illuminance_raw")
|
||||||
sudo cp AB.service /etc/systemd/system/
|
|
||||||
|
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..."
|
echo "Startin Service..."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue