Friday, June 25, 2010

Brightness adjustment on NVidia Cards

    Thanks to nvclock 0.8 which is currently in beta state, we have a great utility: smartdimmer

    This comes into account specially for people (like me) who has some laptop models which is not that easy to adjust screen brightness (in my case, a Sony Vaio which does not work with sonypi).

    With smartdimmer, you can easily increase or decrease screen brightness, or by giving a number between 15 to 100, or by incrementing/decrementing a unit on every call.

    Since only increment/decrement a unit is not enough for a single keypress, I've developed a little script which will increase/decrease 10 units on every call.

    This is the script:


#! /bin/bash

BRIGHTNESS=0

show_error() {
   echo "Usage:"
   echo "$0 increase OR $0 decrease"
}

get_current_brightness() {
   BRIGHTNESS=`smartdimmer -g | awk '{ print $3 }'`
}

increase_brightness() {
   get_current_brightness
   let "BRIGHTNESS+=10"
   `smartdimmer -s $BRIGHTNESS`
}

decrease_brightness() {
   get_current_brightness
   let "BRIGHTNESS-=10"
   `smartdimmer -s $BRIGHTNESS`
}

# programa principal

if ([ -z "$1" ] || [ "$#" -gt 1 ]) || ([ "$1" != "increase" ] && [ "$1" != "decrease" ])
then
   show_error
else
   if [ "$1" == "increase" ]
   then
      increase_brightness
   else
      decrease_brightness
   fi
fi

    You just need to call it with increase or decrease parameter. I hope you find it usefull as I did.