27 lines
602 B
Bash
Executable file
27 lines
602 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# base dir for backlight class
|
|
basedir="/sys/class/backlight/"
|
|
|
|
# get the backlight handler
|
|
handler=$basedir$(ls $basedir)"/"
|
|
|
|
# get current brightness
|
|
old_brightness=$(cat $handler"brightness")
|
|
|
|
# get max brightness
|
|
max_brightness=$(cat $handler"max_brightness")
|
|
|
|
# calculate new brightness %
|
|
new_brightness=$(($old_brightness $1))
|
|
|
|
if [ new_brightness -lt 0 ]; then
|
|
new_brightness = 0
|
|
elif [ new_brightness -gt $max_brightness ]; then
|
|
new_brightness = $max_brightness
|
|
fi
|
|
|
|
# set the new brightness value
|
|
#sudo chmod 666 $handler"brightness"
|
|
echo $new_brightness > $handler"brightness"
|