13.05.2009 20:58

Plight and brightness

Pvol screenshot I wrote about those nice OSD notifications on volume changes, some are in hardware, but GNOME apparently also has its own. Both for volume and brightness changes. Since I wrote pvol I wanted to do something about brightness too, and when I saw some GNOME screenshots yesterday I took a few minutes to do it.

A lot of things happen when you press a brightness hotkey. Hardware generates an ACPI event which gets picked up by acpid. Acpid will run a handler script if you specified one. On some modern distributions quite a few other steps take place. Handler could generate a key-press to be picked up by the GNOME Power Manager which would eventually display the notification. But it could also pass it on to HAL and rely on it to do the "right thing". For purposes of plight I checked respective shell scripts in "/usr/lib/hal/scripts/linux" but they were useless. On top of all that there is also the fact that on most newer laptops, including my Acer, the brightness is changed in hardware. There is no need for any userspace action. Thinking about the approach I decided to make use of acpid and I did a cheap hack on pvol. Renamed it to plight.py, and I call it from an acpid handler with options: "-s -a" to just show the current brightness level (retrieved from ACPI) when I press a hotkey. Let's see the other options:

$ plight -h

Usage: plight [-s] [-c PERCENT] [-a] [-q]

Options:
  -h, --help            show this help message and exit
  -s, --status          display current brightness level
  -c PERCENT, --change=PERCENT
                        increase or decrease brightness to given percentage
  -a, --acpi            make use of ACPI (default is xbacklight)
  -q, --quiet           adjust brightness without the progressbar


Written by anrxc | Permalink | Filed under desktop, code