Created
November 7, 2011 00:12
-
-
Save kjmkznr/1343846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
# dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower.Device string:'Percentage' | |
import dbus | |
bus = dbus.SystemBus() | |
bat0_object = bus.get_object('org.freedesktop.UPower', | |
'/org/freedesktop/UPower/devices/battery_BAT0') | |
bat0 = dbus.Interface(bat0_object, 'org.freedesktop.DBus.Properties') | |
print bat0.Get("org.freedesktop.UPower.Device", "Percentage") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just used it. thanks a lot.
also added battery state
print bat0.Get("org.freedesktop.UPower.Device", "State")