Thursday, February 23, 2012

Change display's brightness on startup

This is a sad story for me. My new Laptop hp Pavilion g4 has an ATI Radeon graphic chip set which don't have a working driver for Linux. So i'm facing lot problems in setting its brightness. As i work more than 20hrs in front of lap, i use minimum level of brightness on the LCD.

But unfortunately shortcut keys don't help me totally at the moment.So, i wanted to add a start up script to set the brightness on start up. here is how i did it. I think some one else may get it useful.

I'm going to use xbacklight tool for this... it can be simply installed using apt packager.

$ sudo apt-get install xbacklight 

setBacklight.sh
 #!/bin/bash  
 case "$1" in  
 start)  
      echo "Setting brigtness to 10..."  
      xbacklight -set 10  
   ;;  
 stop)  
      echo "Setting brigtness to 100..."  
      xbacklight -set 100  
   ;;  
 restart)  
   $0 stop  
   $0 start  
   ;;  
 *)  
      xbacklight -set 10  
   echo "usage: $0 (start|stop|restart)"  
 ;;  
 esac  
 exit 0  

You can check if it works by typing

$./setBacklight.sh restart

so this is a small shell script, but its a little different. This shell gets augment for the action as well.This shell is prepared to run as a init.d script on kernel start-up. To install this you need to to the following coding:


first copy the file to init.d run-level initialization folder

$ sudo cp setBacklight.sh /etc/init.d/

set permission to execute
$ sudo chmod +x /etc/init.d/setBacklight.sh 


then add the script to other runlevels to be executed on system start:

 $ sudo update-rc.d -f setBacklight.sh defaults


BUT.. unfortunately, my Linux Mint destro will reset display brightness on many occasions on system start up. so its no use of doing the above to change the brightness level for me.
Then i had to add a simpler command to Mint's Gnome start up settings to do my work.. ;(

xbacklight -set 10



Now everything works fine... :D

No comments:

Post a Comment