Friday, June 18, 2010

Setting Brightness right on Ubuntu

Well, i accept it. I tried everything available on Google and nothing seems to work for me to control my Lenovo laptop's screen's brightness.
So i wrote a little script to get my work done.

.setbright.sh:
#!/bin/sh

if [ $# -ne 1 ]
then
echo "Usage: bright 50"
exit
fi

x=$((($1*254)/100))
n=$(echo "ibase=10;obase=16;$x" | bc)

sudo setpci -s 00:02.0 F4.B="$n"

#End of setbright.sh



Then modfied my .bashrc as:

alias bright=$HOME/.setbright.sh
bright 50 #Set Brightness to 50%


Now use on command line as:
bright 60


Am happy as of now with this!!