#!/bin/sh ################################################################################ ## BatteryLogger v1.00 by Timo Taskinen (timo.taskinen@iki.fi) ## ## Creative Commons Attribution-Noncommercial-Share Alike 1.0 Finland License ## ## http://creativecommons.org/licenses/by-nc-sa/1.0 ## ################################################################################ # Log file location and filename prefix to use # (battery serial number and filename extension will be added) LOGFILEPREFIX="/Users/user/battery" # Location of ioreg binary (default in OS X 10.5 Leopard is "/usr/sbin/ioreg") IOREGBIN="/usr/sbin/ioreg" # After this there will be dragons. MAXCAPACITY=`$IOREGBIN -l | awk '/MaxCapacity/ { print $5; }'` CYCLECOUNT=`$IOREGBIN -l | awk '/CycleCount/ { print $5; }'` BATTERYSERIALNUMBER=`$IOREGBIN -l | awk '/BatterySerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }'` TIMESTAMP=`date "+%d.%m.%Y %H:%M:%S"` echo "$TIMESTAMP;$MAXCAPACITY;$CYCLECOUNT" >> $LOGFILEPREFIX-$BATTERYSERIALNUMBER.csv