onBatteryPower

Danny Kukawka danny.kukawka at web.de
Wed Oct 26 10:02:10 PDT 2005


On Wednesday 26 October 2005 18:36, David Zeuthen wrote:
> Suggest to use
>
>         /* Find devices with a given capability. */
>         char **libhal_find_device_by_capability (LibHalContext *ctx,
>                                                  const char *capability,
>                                                  int *num_devices,
>                                                  DBusError *error);
>
> instead.

But in this case you get only one ac_adapter device and not the information if 
the AC Adapter is present. With libhal_manager_find_device_string_match() you 
need only one call to get the information. 

>         [davidz at daxter ~]$ hal-find-by-capability --capability
>         ac_adapter
>         /org/freedesktop/Hal/devices/acpi_AC

Same as above. You must now check also for the key ac_adapter.present to know 
if the machine runs on battery. Btw. I could enhance hal-find-by-property to 
get more than strings e.g.:

hal-find-by-property --key <key> --bool <value> 

Danny


More information about the hal mailing list