Question

I'm watching HAL events on DBus, observing when the AC Adapter is removed / plugged-in.

Via dbus-montior, the two events appear the exact same:

unplug event

signal sender=:1.85 -> dest=(null destination) serial=3698 path=/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC0; interface=org.freedesktop.Hal.Device; member=PropertyModified
   int32 1
   array [
      struct {
         string "ac_adapter.present"
         boolean false
         boolean false
      }
   ]

plug-in event

signal sender=:1.85 -> dest=(null destination) serial=3701 path=/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC0; interface=org.freedesktop.Hal.Device; member=PropertyModified
   int32 1
   array [
      struct {
         string "ac_adapter.present"
         boolean false
         boolean false
      }
   ]

However, explicitly querying the ac_adapter.present property in org.freedesktop.Hal does correctly return the device state.

The Question: What are the booleans sent in the PropertyModified event? Does there exist an event I can filter for that will contain information on the adapter's presence, or do I have to explicitly query after receiving the more nebulous 'something happened' message?

The HAL DBus documentation was not particularly helpful, or I'm looking in the wrong place.

Était-ce utile?

La solution

do I have to explicitly query after receiving the more nebulous 'something happened' message?

Yes. If you use a DBus browser like d-feet, you will see that the org.freedesktop.Hal.Device interface on the AC adapter object has methods

  • GetProperty(String property) -> Variant
  • GetPropertyBoolean(String property) -> Boolean - likely useful for ac_adapter.present
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top