Sunday, May 4, 2014

Using Upstart in Ubuntu 12.04 to set screen brightness during boot in Asus Eee PC

First I wrote a small script in /usr/local/bin to set the brightness to the lowest possible value (the lowest value is plenty bright for my eyes):

 $ cat /usr/local/bin/set-screen-brightness.sh   
 #!/bin/bash  
 echo $1 > /sys/class/backlight/acpi_video0/brightness  

Then I made the script executable. Next I wrote the following upstart script:

 $ cat /etc/init/my-brightness.conf   
 description "Set laptop screen to lowest brightness level"  
 start on runlevel [2]  
 script  
   exec /usr/local/bin/set-screen-brightness.sh 0  
 end script  

(My default runlevel (as indicated by running the runlevel command) is 2)

At the next boot, my screen's brightness is automatically set to the provided 0 value.

If I wanted to start the 'my-brightness' upstart service anytime, I would simply use the following command:

 $ sudo service my-brightness start  

No comments: