Advertisement
Guest User

xbacklight script for Lenovo Y500

a guest
Mar 4th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.46 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Script for setting the correct brightness for the backlight.
  4. # Depends on: xbacklight and inotify-tools,
  5. # Which can be installed by running:
  6. #       `sudo apt-get install xbacklight inotify-tools`
  7. #
  8. # Author: Esteban Serrano Roloff <e.serrano.r (at) me.com>
  9. #
  10. # Tested on a Sony VAIO VPCCW15FL
  11. # running Ubuntu 12.04
  12. # 2013-03-27 (YYYY-MM-DD)
  13.  
  14. # Setup the correct paths (look inside /sys/class/backlight/)
  15. current_brightness_path="/sys/class/backlight/acpi_video0/brightness"
  16. max_brightness_path="/sys/class/backlight/acpi_video0/max_brightness"
  17. # To find the correct value for min_brightness, make the
  18. # brightness meter go to its minimum (by repeatedly pressing
  19. # the brightness down key), even if the actual brightness stays
  20. # the same, and then run on a terminal:
  21. #       `cat /sys/class/backlight/sony/brightness`
  22. min_brightness=0
  23.  
  24.  
  25. #### No editing needed beyond this line (I hope) ####
  26. max_brightness=`cat $max_brightness_path`
  27. range=${max_brightness-min_brightness}
  28.  
  29.  
  30.  
  31. # Set the correct brightness level on start up.
  32. current_brightness=`cat $current_brightness_path`
  33. let current_brightness_pctg=100*$current_brightness/$range
  34. xbacklight =$current_brightness_pctg
  35.  
  36. # Listen for brightness changes, forever.
  37. while inotifywait -e close_write $current_brightness_path; do
  38.  
  39.     current_brightness=`cat $current_brightness_path`
  40.     let current_brightness_pctg=100*$current_brightness/$range
  41.     xbacklight =$current_brightness_pctg
  42.  
  43. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement