NoPaste Service
DOWNLOAD
Language: Bash
Author: Matrix86
Description: Backlight Samsung
Date: 12/12/10 15:31
  1. #!/bin/bash
  2. # increase/decrease/set/get the backlight brightness (value 7 13 20 30 45 60 80 100)
  3. #
  4.  
  5. # allowed values
  6. values=( 7 13 20 30 45 60 80 100 )
  7. actual=`cat /proc/acpi/video/NVID/LCD/brightness | grep current | cut -d ' ' -f2`
  8. for i in `seq 0 7`;
  9. do
  10.         if [ "$actual" = "${values[$i]}" ]; then
  11.                 index=$i
  12.         fi
  13.  
  14. done
  15.  
  16.  
  17. case "$1" in
  18.        up)
  19.                #calculate new brightness
  20.                if [ $index -lt 7 ]; then
  21.                  (( index++ ))
  22.                fi
  23.                new="${values[$index]}"
  24.                echo "$0: increasing brightness from $actual to $new"
  25.                echo $new > /proc/acpi/video/NVID/LCD/brightness
  26.                ;;
  27.        down)
  28.                #calculate new brightness
  29.                if [ $index -gt 0 ]; then
  30.                  (( index-- ))
  31.                fi
  32.                new="${values[$index]}"
  33.                echo "$0: decreasing brightness from $actual to $new"
  34.                echo $new > /proc/acpi/video/NVID/LCD/brightness
  35.                ;;
  36.        get)
  37.                echo "$0: current brightness is $actual"
  38.                ;;
  39.        *)
  40.                echo "usage: $0 {up|down|get}"
  41.                ;;
  42. esac
  43. exit 0