Laptop screen brightness control script
This commit is contained in:
		
							parent
							
								
									e54a1e7869
								
							
						
					
					
						commit
						ba1030783b
					
				
							
								
								
									
										40
									
								
								bin/laptop-screen-brightness
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										40
									
								
								bin/laptop-screen-brightness
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,40 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Keys: XF86MonBrightnessUp, XF86MonBrightnessDown
 | 
			
		||||
 | 
			
		||||
class=intel_backlight
 | 
			
		||||
dir=/sys/class/backlight/$class
 | 
			
		||||
cur=$(cat $dir/brightness)
 | 
			
		||||
max=$(cat $dir/max_brightness)
 | 
			
		||||
 | 
			
		||||
step=$(("$2" + 0))
 | 
			
		||||
cur_pct=$((100 * $cur / $max))
 | 
			
		||||
 | 
			
		||||
case "$1" in
 | 
			
		||||
	"up")
 | 
			
		||||
		echo "up $2%"
 | 
			
		||||
		target_pct=$(($cur_pct + $2))
 | 
			
		||||
		;;
 | 
			
		||||
	"down")
 | 
			
		||||
		echo "down $2%"
 | 
			
		||||
		target_pct=$(($cur_pct - $2))
 | 
			
		||||
		;;
 | 
			
		||||
	*)
 | 
			
		||||
		echo "Backlight at $cur/$max ($cur_pct%)"
 | 
			
		||||
		exit 0
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
if [ "$target_pct" -lt "0" ]; then
 | 
			
		||||
	target_pct=0
 | 
			
		||||
fi
 | 
			
		||||
if [ "$target_pct" -gt "100" ]; then
 | 
			
		||||
	target_pct=100
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
target_val=$(($max * $target_pct / 100))
 | 
			
		||||
 | 
			
		||||
echo "Backlight at $cur/$max ($cur_pct%)"
 | 
			
		||||
echo "Target $target_val ($target_pct%)"
 | 
			
		||||
echo "Dest $dir/brightness"
 | 
			
		||||
echo $target_val > $dir/brightness
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user