battery.py first examples in python (very slow) battery.c uses the freebsd sysctl system calls to get the battery state which is much faster.