DeviceKit is a modular hardware abstraction layer designed for use in Linux systems that is designed to simplify device management and replace the current monolithic Linux HAL. DeviceKit includes the ability to enumerate system devices and send notifications when hardware is added or removed from the computer system.
DBus Interfaces provided by DeviceKit are following
- org.freedesktop.DeviceKit.Power - Power interface
- org.freedesktop.DeviceKit.Power.Device - Device interface
- org.freedesktop.DeviceKit.Power.QoS- QoS interface
Running ths script in virtual machine will show only one device AC. Running on real device will show other devices as well e.g. battery etc.
State is numberical value with following assignments
- 0: Unknown
- 1: Charging
- 2: Discharging
- 3: Empty
- 4: Fully charged
- 5: Pending charge
- 6: Pending discharge
That to get the battery percentage we need to read "Percentage" parameter of "org.freedesktop.DeviceKit.Power" interface.
Use the same function above passing "Percentage" argument