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]
 | 
			
		||||
Description=Mac like automatic brightness  as service
 | 
			
		||||
Description=Mac-like-automatic-brightness  as service
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=simple
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
# Mac-like-automatic-brightness
 | 
			
		||||
A simple script to provide a "Mac" like automatic brightness adjustemnt/ animation. 
 | 
			
		||||
## 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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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```
 | 
			
		||||
 | 
			
		||||
* 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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
```AnimationDelay```  Speed of the brightness animation(delay between each step), recomended screen refreshrate in seconds
 | 
			
		||||
 | 
			
		||||
```MaxScreenBrightness``` The highest value your screen supports, check ```/sys/class/backlight/intel_backlight/max_brightness``` on framework laptops
 | 
			
		||||
```AnimationDelay```  Speed of the brightness animation(delay between each step), recomended screen refreshrate in seconds (0.16 of 60Hz)
 | 
			
		||||
 | 
			
		||||
```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
 | 
			
		||||
 | 
			
		||||
```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
 | 
			
		||||
#
 | 
			
		||||
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