#!/bin/bash
# increase/decrease/set/get the backlight brightness (value 7 13 20 30 45 60 80 100)
#
# allowed values
values=( 7 13 20 30 45 60 80 100 )
actual=`cat /proc/acpi/video/NVID/LCD/brightness | grep current | cut -d ' ' -f2`
for i in `seq 0 7`;
do
if [ "$actual" = "${values[$i]}" ]; then
index=$i
fi
done
case "$1" in
up)
#calculate new brightness
if [ $index -lt 7 ]; then
(( index++ ))
fi
new="${values[$index]}"
echo "$0: increasing brightness from $actual to $new"
echo $new > /proc/acpi/video/NVID/LCD/brightness
;;
down)
#calculate new brightness
if [ $index -gt 0 ]; then
(( index-- ))
fi
new="${values[$index]}"
echo "$0: decreasing brightness from $actual to $new"
echo $new > /proc/acpi/video/NVID/LCD/brightness
;;
get)
echo "$0: current brightness is $actual"
;;
*)
echo "usage: $0 {up|down|get}"
;;
esac
exit 0