-->

..:: seize the day ::..

March 29, 2009

Using xbrightness to Manage Screen Brightness

Filed under: IT stuff

In openSUSE 11.1 installation on my HP 2230s laptop, I cannot manage to have Function (fn) keys working. In my other HP laptop which is V3108TU with openSUSE 11.0 the fn keys is working perfectly. I don’t understand why, maybe I should wait for 11.2 with the newer kernel. I don’t want to experiment with newer kernel in this installation, considering it is my working laptop. What I need actually is only the screen brightness function keys which is fn-f7 to decrease it and fn-f8 for increasing the brightness.

I use KDE 4.2 with Battery Monitor / Power Management widget. I set the Power Profile in this widget to Performance when using AC adaptor and become Powersave on battery power. But on those two conditions I cannot manage to manually adjust the screen brightness. I do need to change that manually depend on the light condition. With the fn keys for managing the screen brightness doesn’t work I stuck with this condition.

I do experimenting a bit though :-) I run xev, it captures nothing with fn-f7 and fn-f8 keys. Though it captures fn-f2, fn-f3, fn-f5, fn-f9, fn-f10, fn-f11, fn-f12 but with no effect to the systems.

If I press fn-f2 the xev result is:

KeyRelease event, serial 34, synthetic NO, window 0x3600001,
    root 0x7d, subw 0x0, time 4931507, (-570,455), root:(527,480),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Fn-f5 result is:  

KeyRelease event, serial 34, synthetic NO, window 0x3600001,
    root 0x7d, subw 0x0, time 5005356, (-436,532), root:(661,557),
    state 0x0, keycode 223 (keysym 0x1008ff10, XF86Standby), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

But xev with fn-f7 and fn-f8 results is:

KeyRelease event, serial 34, synthetic NO, window 0x3600001,
    root 0x7d, subw 0x0, time 5050624, (-663,480), root:(434,505),
    state 0x0, keycode 212 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Also the result of "xbacklight -get" is 100.000000 when I use electric power. I try to change "xbacklight -set 60.000000", no result in screen brightness. 

So I try to check a bit deeper. I search for ACPI setting for vga, and found that on /proc/acpi/video there is GFX0 directory that consist of several sub-directory DD01 until DD05 that each of it contains a file named "brightness". What’s strange is the file brightness contain nothing but <not supported> line. I try to google to find another alternatives on how to manage the screen brightness. I come up with this very short site but it is enough to give me the clue. I go to http://software.opensuse.org and find this result. I installed it with the 1-click install and voila …… I can adjust the screen brightness. 

The usage is very simple, and the help gives straightforward information

medwinz@slowhand:~> xbrightness –help
xbrightness builds a brightness ramp for X11.

usage:  xbrightness BRIGHTNESS [ GBASE ]

where BRIGHTNESS is a number from 0 to 65535.
where GBASE is a float number from 0.0 to 10.0. (default=1.0)

For me the settings are:

  • "xbrightness 35000" for low brightness
  • "xbrightness 45000" for medium brightness
  • "xbrightness 55000" for high brightness
  • "xbrightness 65535" for maximum brightness

Please note that the setting with this is not persistent, and you should adjust manually every time you login or reboot. You can make a short script by yourself to automatically call xbrightness to set the screen brightness in the login/restart.

Have a lot of fun :-)