Advertisement
Guest User

Brightness buttons handling via acpid

a guest
Aug 3rd, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. # cat /etc/acpi/actions/brightness.sh
  2.  
  3. #! /bin/bash
  4.  
  5. case $1 in
  6.         -|+) ;;
  7.         *) exit 1;;
  8. esac
  9.  
  10. dev=/sys/class/backlight/intel_backlight
  11. max=$(< $dev/max_brightness)
  12. cur=$(< $dev/brightness)
  13. step=$(( max / 50 ))
  14.  
  15. test $((cur * 100 / max)) -lt 21 && step=$(( max / 200 ))
  16.  
  17. brightness=$((cur $1 step))
  18.  
  19. test "$brightness" -lt 0 && brightness=0
  20. test "$brightness" -gt "$max" && brightness="$max"
  21.  
  22. echo "$brightness" > $dev/brightness
  23.  
  24. # cat /etc/acpi/events/brightness_down
  25.  
  26. event=video.brightnessdown
  27. action=/etc/acpi/actions/brightness.sh -
  28.  
  29. # cat /etc/acpi/events/brightness_up
  30.  
  31. event=video.brightnessup
  32. action=/etc/acpi/actions/brightness.sh +
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. // (c) Artem S. Tashkinov Jul 23 2016 10:03 GMT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement