Navigate / search

How to setup brightness keys on Ubuntu based Compaq C700

I’ve been using my Ubuntu-based Compaq C700 (specifically the C793TU) for a while now. For some reason during one of my updates, the brightness special function keys stopped working. I’ve never really gotten to fix the problem until now.

An idea of how to do it actually came from Valdir Silveira Jr’s “Ubuntu in Notebook” post (the post is in Portuguese but I used the ever so useful Google translation service) which did a trackback to my post about installing Ubuntu Linux on Compaq C700. Valdir showed how to adjust the brightness using a terminal session:

echo -n 50 > /proc/acpi/video/OVGA/DD03/brightness

I decided to concoct a couple of bash scripts and map them to the “increase brightness” and “decrease brightness” function keys to allow me to adjust the brightness again.

I’m using Ubuntu Hardy Heron (version 8.04) on my notebook. The function keys for brightness is actually handled by the ACPI kernel modules. Under Ubuntu different shell scripts are called when certain special keys like sleep, volume mute and brightness. The shell scripts are located in the /etc/acpi directory.

Two scripts control the brightness up and brightness down keys. The video_brightnessdown.sh file is for the latter while the video_brightnessup.sh file is for the former.

Note: Create backups of the files so that you can go back to them in case the scripts doesn’t work in your system.

Now replace the contents of the video_brightnessup.sh file with the following:

#!/bin/bash

# set a maximum value
max="`cat /proc/acpi/video/OVGA/DD03/brightness | grep levels | awk '{print $13;}'`"

# get the current value
curr_brightness="`cat /proc/acpi/video/OVGA/DD03/brightness | grep current | awk '{print $2;}'`"

# add 10 to change brightness to next lower setting
brightness=`expr $curr_brightness + 10`

# don't allow a value larger than $max
if [ ${brightness} -ge ${max} ]
then
brightness=${max}
fi

# now set the proc variable to the new value
echo ${brightness} > /proc/acpi/video/OVGA/DD03/brightness

Replace the contents of the video_brightnessdown.sh with the following:

#!/bin/bash

# set a minimum value
min="`cat /proc/acpi/video/OVGA/DD03/brightness | grep levels | awk '{print $4;}'`"
max="`cat /proc/acpi/video/OVGA/DD03/brightness | grep levels | awk '{print $13;}'`"

# get the current value
curr_brightness="`cat /proc/acpi/video/OVGA/DD03/brightness | grep current | awk '{print $2;}'`"

# subtract 10 to change brightness to next lower setting
brightness=`expr $curr_brightness - 10`

#   don't allow a value smaller than $min
if [ ${brightness} -le ${min} ]
then
   brightness=${min}
fi

# now set the proc variable to the new value
echo ${brightness} > /proc/acpi/video/OVGA/DD03/brightness

After saving the files, your brightness keys should now start working.

Thanks Valdir. Enjoy!

Gerry Ilagan

Gerry Ilagan is into mobile apps and WordPress development at @speeqs. He loves to write about electronics, the Internet of Things, mobile phones, and #crazyideas.

Comments

arcanedata
Reply

leet
you own my brightness keys
well done

Leave a comment

name*

email* (not published)

website