onBatteryPower

Danny Kukawka danny.kukawka at web.de
Wed Oct 26 09:13:57 PDT 2005


On Wednesday 26 October 2005 17:38, Richard Hughes wrote:
> > We have already a key for this: ac_adapter.present.
>
> Could we just copy this key to a computer node so we don't have to find
> all devices with capability "ac_adapter"?

What do you try to do with capability "ac_adapter"?

I would use:

char **libhal_manager_find_device_string_match (LibHalContext *ctx,
                                                const char *key,
                                                const char *value,
                                                int *num_devices,
                                                DBusError *error);

with key=ac_adapter.present, value=false and check if num_devices >= 1

Btw: I don't see the case where we have more than one device with this 
property.

> We want to make the "glue" bit that queries hal as simple as possibly,
> hopefully just reading one key.

It's easy as you can see.

> >  At least you could also check
> > battery.rechargeable.is_discharging to detect if run on battery.
> What about multiple batteries? We would have to check each one.

Same as above with key=battery.rechargeable.is_discharging and value=true and 
check for num_devices >= 1.

Danny


More information about the hal mailing list