Add script to controll backlight brightness

This commit is contained in:
finga 2024-04-27 14:37:38 +02:00
parent d1b8f48314
commit 378a7275bc

24
backlight_brightness.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
set -e
usage() {
echo "usage: $0 value brightness_path"
exit 1
}
if [ $# -ne 2 ]; then
usage
fi
actual_brightness=$(cat "$2/actual_brightness")
max_brightness=$(cat "$2/max_brightness")
new_brightness=$(("$actual_brightness" + "$1"))
if [ "$new_brightness" -gt "$max_brightness" ]; then
new_brightness="$max_brightness"
elif [ "$new_brightness" -lt "0" ]; then
new_brightness="0"
fi
echo "$new_brightness" > "$2/brightness"