Ubuntu 8.04 Laptop Screen Brightness

May 14, 2008

hardy_splash.jpgIt seems like every other day I’m posting an article about Ubuntu these days. Unfortunately most of them appear to be about solving issues that should have been sorted out at beta stage.

After applying the fix for the heat issues, My laptop is runnig like a dream, very rarely getting above 50C whereas previously it would soar to the mid 70C! Now its the turn of the LCD screen brightness issues that seem to be plagueing Hardy Heron on some laptops.

The issue is that no matter what you try, the combination of Fn and Up Arrow/Down Arrow just fails to register with the laptop and you can’t adjust screen brightness. If you’re experiences are anything like mine, then you’ll know that even if you add the Gnome brightness applet, nothing happens.

This workaround is still very much a work in progress but I’ve found that if you bring up a terminal and enter:

sudo gedit /etc/acpi/video_brightnessup.sh

and completely replace the contents with:

#!/bin/bash

CURRENT=$(grep “current:” /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness |awk ‘{print $2}’)
case “$CURRENT” in

100)
echo -n 100 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
87)
echo -n 100 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
75)
echo -n 87 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
62)
echo -n 75 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
50)
echo -n 62 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
37)
echo -n 50 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
25)
echo -n 37 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
12)
echo -n 25 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
*)
echo -n 100 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness ;
;;
esac

You’ll need to look at your file structure for the (Laptop dependent) part. Now edit the brightnessdown file like so:

sudo gedit /etc/acpi/video_brightnessdown.sh

So that it looks like this:

#!/bin/bash

CURRENT=$(grep “current:” /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness |awk ‘{print $2}’)

case “$CURRENT” in

12)
echo -n 12 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
25)
echo -n 12 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
37)
echo -n 25 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
50)
echo -n 37 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
62)
echo -n 50 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
75)
echo -n 62 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
87)
echo -n 75 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
100)
echo -n 87 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness;
;;
*)
echo -n 50 > /proc/acpi/video/(LAPTOP DEPENDENT)/LCD/brightness ;
;;
esac

Save and close the files. Now if you’re lucky, try your key combination to adjust screen brightness. If it works then give yourself a pat on the back and go grab a coffee. If not, then you must have my laptop because it didn’t work for me either - or so I thought.

What you should now be able to do is manually alter the screen brightness by calling up a root terminal and entering:

cat /proc/acpi/video/(Laptop dependent)/LCD/brightness

This now gives an output of the brightness scaling capable by your laptop. Again, you’ll need to look at your file structure for the (Laptop dependent) part.

Then enter:

echo # > /proc/acpi/video/(Laptop dependent)/LCD/brightness

Where # represents the numeric value you wish to change the brightness to, and your screen should respond.

The only thing left to do is to create a shell script and link it to key presses. This can be tricky as Ubuntu doesn’t even recognise the fact that my key combinations are being pressed.

I’ll keep the site updated with how I get on and hopefully some of what I’ve wrote will have helped you.

UPDATE

After numerous weeks searching through forums, scripting tutorials and such like, I have finally managed to implement a fairly comprehensive solution for this problem, administrable from two applets locked into the gnome-panel.

Copy and Paste this entire script, the instructions are in it marked with a #


#!/bin/sh
# adjust lcd brightness on Dell Inspiron 1501 - 080303 Alex P Janssen Jr - alex@ourwoods.org
# customised for Samsung X22 - NP-X22 Phil Heaton - philheaton@gmail.com
# INSTRUCTIONS:
# Save this script to a file named brightup.sh in /home/yourusername/bin
# Make it executable: chmod +x brightup.sh
# Save yourself having to run it in a terminal and enter your password each time
# edit sudoers: sudo visudo
# add to sudoers: yourusername ALL=(ALL) NOPASSWD:/bin/bash
# save and exit
# link brightup and brightdn to brightup.sh:
# ln -s /home/yourusername/bin/brightup.sh /home/yourusername/bin/brightup
# ln -s /home/yourusername/bin/brightup.sh /home/yourusername/bin/brightdn
# Add a couple of custum launchers to your panel ( I run Gnome )
# Right-click the panel and select Add to Panel
# Click Custom Launcher
# Type=Application, Name=Darker, Command=sudo bash -c /home/yourusername/bin/brightdn
# Select a down-arrow for an icon and Close
# Do the same for brightup, except set the name to Lighter and pick an up-arrow
#
# check our id
#echo `id`
ourname=$0
ourname=`basename "$ourname"`
xx=`cat /proc/acpi/video/ATIM/LCD/brightness | grep current | cut -c 9-`
curbright=`echo $xx`
# check process name and current brightness setting
#echo "${ourname},${curbright}:"
case $curbright in
0) # after boot my brightness value is 0
#echo "10"
echo -n 10 >/proc/acpi/video/ATIM/LCD/brightness
;;
10) if [ "$ourname" = "brightup" ]; then
#echo “10 to 30″
echo -n 30 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
30) if [ "$ourname" = "brightup" ]; then
#echo “30 to 40″
echo -n 40>/proc/acpi/video/ATIM/LCD/brightness
else
echo -n 10 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
40) if [ "$ourname" = "brightup" ]; then
#echo “40 to 50″
echo -n 50 >/proc/acpi/video/ATIM/LCD/brightness
else
echo -n 20 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
50) if [ "$ourname" = "brightup" ]; then
#echo “50 to 60″
echo -n 60 >/proc/acpi/video/ATIM/LCD/brightness
else
echo -n 40 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
60) if [ "$ourname" = "brightup" ]; then
#echo “60 to 70″
echo -n 70 >/proc/acpi/video/ATIM/LCD/brightness
else
echo -n 50 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
70) if [ "$ourname" = "brightup" ]; then
#echo “70 to 80″
echo -n 80 >/proc/acpi/video/ATIM/LCD/brightness
else
echo -n 60 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
80) if [ "$ourname" = "brightup" ]; then
#echo “80 to 100″
echo -n 100 >/proc/acpi/video/ATIM/LCD/brightness
else
echo -n 70 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
100) if [ "$ourname" != "brightup" ]; then
echo -n 80 >/proc/acpi/video/ATIM/LCD/brightness
fi
;;
esac
exit 0

Hopefully that will be of some help, Ive now got full control over my laptop brightness.

If you find it doesn’t work for you you may need to alter the numeric values to suit your computer’s screen brightness capablities. To find out what they are, run this command from a terminal:
cat /proc/acpi/video/ATIM/LCD/brightness

You also need to be aware that the ATIM part of this command is laptop dependent, follow the path in Nautilus to find the exact route for you.

Enjoy!

Comments

Got something to say?






Warning: stristr() [function.stristr]: Empty delimiter in /usr/home/linuxrev/public_html/wp-content/plugins/wassup/wassup.php on line 2093