set-brightness and get-brightness

Richard Hughes hughsient at
Sun Sep 25 06:23:37 PDT 2005

At the moment these scripts receive and return the values in
percentages. Unfortunately some laptops have multiples of brightness
levels that are not easily expressed in non-integer percent.

For instance, passing the value of 14.285714286 (100/7) to the
set-brightness script does nothing, as the 

let "value = ( $percentage * $HAL_PROP_LAPTOP_PANEL_NUM_LEVELS ) / 100"

evaluates to "syntax error in expression" which means the command fails
to evaluate and junk is written to the proc files.

As I have found whilst using this interface, it is more difficult to
convert to non-integer percentage values, and back again safely, that to
just read the max levels and send a nice integer value:

0 < x < laptop_panel.num_levels

This problem has caused all sorts of funny bug reports in GNOME Power
Manager, with the brightness not being set correctly.

I propose making the scripts send and receive the values from hardware
(i.e. from 0..X), and then just scale those for the user in percent --
it's certainly easier this way from a developer perspective, and the
user can still be presented with a slider expressed in "%" in the end

The user isn't likely to use dbus-send or invoke directly
hal-system-lcd-set-brightness, but only through application programs
such as a brightness applet or policy daemon, so we should make the
programming API easy to use for these programs.

Putting it bluntly, doing it this way fixes the bugs in g-p-m with the
"brightness weirdness" bugs.

There is a simple patch attached. I really want to commit this one as
the LCD brightness stuff is not going to work reliably otherwise.


More information about the hal mailing list