summaryrefslogtreecommitdiffstats
path: root/powermanager/hal-test.py
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-13 05:43:39 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-13 05:43:39 +0000
commit19ae07d0d443ff8b777f46bcbe97119483356bfd (patch)
treedae169167c23ba7c61814101995de21d6abac2e8 /powermanager/hal-test.py
downloadtde-guidance-19ae07d0d443ff8b777f46bcbe97119483356bfd.tar.gz
tde-guidance-19ae07d0d443ff8b777f46bcbe97119483356bfd.zip
Added KDE3 version of KDE Guidance utilities
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kde-guidance@1102646 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'powermanager/hal-test.py')
-rw-r--r--powermanager/hal-test.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/powermanager/hal-test.py b/powermanager/hal-test.py
new file mode 100644
index 0000000..f9ef90c
--- /dev/null
+++ b/powermanager/hal-test.py
@@ -0,0 +1,35 @@
+import dbus
+
+bus = dbus.SystemBus()
+hal_manager_obj = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
+hal_manager = dbus.Interface(hal_manager_obj, "org.freedesktop.Hal.Manager")
+#device_names = hal_manager.GetAllDevices()
+
+ac = hal_manager.FindDeviceByCapability("ac_adapter")
+
+#all_devices = hal_manager.GetAllDevices()
+
+#for n in device_names: print n
+#obj = bus.get_object("org.freedesktop.Hal", u'/org/freedesktop/Hal/devices/acpi_AC')
+#obj.GetAllProperties()
+
+name = ac[0]
+device_dbus_obj = bus.get_object("org.freedesktop.Hal" ,ac[0])
+properties = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
+
+try:
+ parent_name = properties["info.parent"]
+except KeyError:
+ # no parent, must be parent of virtual_root
+ parent_name = "/"
+except TypeError:
+ print "Error: no properties for device %s"%name
+ #continue
+print properties['ac_adapter.present']
+#for p in properties:
+# print p, " :: ", properties[p]
+if properties['ac_adapter.present']:
+ print "plugged in"
+else:
+ print "unplugged"
+