Skip to content

Instantly share code, notes, and snippets.

@gmorell
Created November 10, 2015 18:43
Show Gist options
  • Save gmorell/c1cec4fbcefae6c63e5a to your computer and use it in GitHub Desktop.
Save gmorell/c1cec4fbcefae6c63e5a to your computer and use it in GitHub Desktop.
:<
#!/usr/bin/env python
import os, sys
def get_state():
val = os.popen("adb shell dumpsys battery | grep level").read()
if val:
output = val.strip().rsplit("level: ")[1]
output = "%s%% \n" % output
else:
output = "Phone Disconnected \n"
return output
if __name__ == "__main__":
val = get_state()
sys.stdout.write(val)
sys.stderr.write(val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment