Created
December 7, 2011 02:28
-
-
Save yunazuno/1441153 to your computer and use it in GitHub Desktop.
Log the battery stete to a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Log the battery stete to a file | |
# Sources of battery information | |
PROC_INFO='/proc/acpi/battery/BAT0/info' | |
PROC_STATE='/proc/acpi/battery/BAT0/state' | |
# Get the current state | |
type=`grep "model number:" $PROC_INFO | awk -e '{print $3}'` | |
current=`grep "remaining capacity:" $PROC_STATE | awk -e '{print $3}'` | |
last_full=`grep "last full capacity:" $PROC_INFO | awk -e '{print $4}'` | |
# Save to the file | |
output=$HOME/.battery_$type.log | |
id=`touch $output && wc -l $output | awk -e '{print $1}'` | |
datetime=`date +%Y%m%d%H%M%S` | |
line="$id $datetime $last_full $current" | |
echo $line >> $output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment