Something along this line should work. It could either run with a loop to log, or be called from cron:
#!/bin/sh
logfile="/var/log/battery-stats"
get_logline() {
secstamp=$(date +%s)
stamp=$(date +"%Y/%m/%d %H:%M:%S")
for f in /sys/class/power_supply/BAT*; do
enow=$(cat $f/energy_now)
efull=$(cat $f/energy_full)
percent=$((100 * $enow / $efull))
remaining=0
break
done
echo $secstamp $percent $state $stamp $remaining
}
get_logline >> $logfile
--
Happy hacking
Petter Reinholdtsen

