Sony VAIO brightness control script for Ubuntu (Geforce cards)

This evening I want to share with you this little script that I wrote for my personal use.
This script need the module “smartdimmer” (Change LCD brightness on Geforce cards), you can found it on the Ubuntu repository, than it’s enough to write on console

$ sudo apt-get smartdimmer

For test if the module works just try to set a new brightness value by typing

$ smartdimmer -s 50

If the module works for your laptop you can use the following script for change brightness directly from your keyboard.


File: brightness.sh

#!/bin/bash
maxbrightness=95
curbrightness=$(smartdimmer --get | grep -o [0-9][0-9][0-9]*)
let brightness=$curbrightness
let factor=5

if [ $# -gt 0 ]; then
 if [ $1 = "+" ]; then
 if [ $curbrightness -lt $maxbrightness ]; then
 let brightness=$brightness+$factor;
 fi
 fi

 if [ $1 = "-" ]; then
 if [ $curbrightness -gt 20 ]; then
 let brightness=$brightness-$factor;
 fi
 fi
fi

smartdimmer --set $brightness

Now put this script in your home directory and use the tool Preferences -> Keyboard Shortcut for associate the preferred keys to the following commands.

Increase brightness: brightness.sh +
Decrease brightness: brightness.sh –