Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script for setting the correct brightness for the backlight.
- # Depends on: xbacklight and inotify-tools,
- # Which can be installed by running:
- # `sudo apt-get install xbacklight inotify-tools`
- #
- # Author: Esteban Serrano Roloff <e.serrano.r (at) me.com>
- #
- # Tested on a Sony VAIO VPCCW15FL
- # running Ubuntu 12.04
- # 2013-03-27 (YYYY-MM-DD)
- # Setup the correct paths (look inside /sys/class/backlight/)
- current_brightness_path="/sys/class/backlight/acpi_video0/brightness"
- max_brightness_path="/sys/class/backlight/acpi_video0/max_brightness"
- # To find the correct value for min_brightness, make the
- # brightness meter go to its minimum (by repeatedly pressing
- # the brightness down key), even if the actual brightness stays
- # the same, and then run on a terminal:
- # `cat /sys/class/backlight/sony/brightness`
- min_brightness=0
- #### No editing needed beyond this line (I hope) ####
- max_brightness=`cat $max_brightness_path`
- range=${max_brightness-min_brightness}
- # Set the correct brightness level on start up.
- current_brightness=`cat $current_brightness_path`
- let current_brightness_pctg=100*$current_brightness/$range
- xbacklight =$current_brightness_pctg
- # Listen for brightness changes, forever.
- while inotifywait -e close_write $current_brightness_path; do
- current_brightness=`cat $current_brightness_path`
- let current_brightness_pctg=100*$current_brightness/$range
- xbacklight =$current_brightness_pctg
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement