IdeaMonk

thoughts, ideas, code and other things...

Saturday, April 24, 2010

Stupid power meter script


#!/usr/bin/env python
# Stupid power meter written in college bus while riding back home
# in absence any patience of learning how awesome wm does it
#

import os

remaining_max_magic = "cat /proc/acpi/battery/BAT0/info /proc/acpi/battery/BAT0/state | grep -E '(remaining|last)' | cut -f2 -d: | sed -e s/mAh// | xargs echo"

status = [float(x) for x in os.popen (remaining_max_magic).read().split()]
print "Remaining - %.2f%%" % (status[1] / status[0] *100)


Usage -
ideamonk@pebble:~$ pmeter
Remaining - 67.35%
ideamonk@pebble:~$

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home