Comment 23 for bug 173652

Revision history for this message
Michael Doube (michael-doube) wrote : Re: unable to adjust screen brightness on recent Sony Vaio notebooks

OK. Today dumb work decided that it would be great to have guys installing new windows in the lab, and didn't tell anyone. So here I am in the foyer hacking Ubuntu to get away from the annoying sound of masonry drills, instead of writing the code I'm meant to...

I've re-written jeannich's script to work with xbacklight.

To set up the file where brightness is stored, you have to
]$ mkdir /etc/acpi/var/
]$ cat 50 > /etc/acpi/var/brightness

There's only one snag, you have to run this during your xsession:
]$ sudo /etc/init.d/acpid restart

Also, GNOME appears to be totally ignorant of brightness, so no icon is echoed to the screen as brightness is adjusted.
A hybrid version of these scripts would be useful for those of us with both Intel 965 and nVidia 8400M GS cards (i.e all the recent SZ's) so that the Fn keys work in both SPEED or STAMINA modes

Save this script as /etc/acpi/sonybright.sh

#!/bin/bash
export DISPLAY=:0
function adjust
{
   BRIGHTNESS=$1
   if [ $BRIGHTNESS -ge 100 ]; then
      BRIGHTNESS=100
   fi

   if [ $BRIGHTNESS -le 0 ]; then
      BRIGHTNESS=0
   fi

   echo $BRIGHTNESS >/etc/acpi/var/brightness
   B=$BRIGHTNESS
   echo “adjusting brightness to $B”
   /usr/bin/xbacklight -set $B 2>/tmp/sonybright.log
}

BRIGHTNESS=$(cat /etc/acpi/var/brightness)

if [ "x$1" = "xdown" ]; then
   BRIGHTNESS=$(( $BRIGHTNESS - 10 ))
   adjust $BRIGHTNESS
elif [ "x$1" = "xup" ]; then
   BRIGHTNESS=$(( $BRIGHTNESS + 10 ))
   adjust $BRIGHTNESS
else
   echo >&2 Unknown argument $1
fi