The simplest is getting the battery level. I use D-Bus to access battery charge percentage level with Python. It's not Maemo specific, but a cross platform API that works on any Linux / FreeDesktop-compliant environment.
Similar API is available through System Information API in Qt Mobility. But I'm not sure how to access Qt Mobility through Python at the moment.
#!/usr/bin/python
import dbus
bus = dbus.SystemBus()
hal_obj = bus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
hal = dbus.Interface(hal_obj,
'org.freedesktop.Hal.Manager')
uids = hal.FindDeviceByCapability('battery')
dev_obj = bus.get_object('org.freedesktop.Hal', uids[0])
print 'battery percent', \
dev_obj.GetProperty('battery.charge_level.percentage')
No comments:
Post a Comment
Be the first to comment!