Skip to content

Instantly share code, notes, and snippets.

@brb
Created June 3, 2017 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brb/f753afbf3b295a2673dd54ee9089fc0b to your computer and use it in GitHub Desktop.
Save brb/f753afbf3b295a2673dd54ee9089fc0b to your computer and use it in GitHub Desktop.
battery.sh
#!/bin/sh
# * * * * * battery.sh /home/brb/Dropbox/battery-stats.txt
set -eu
for b in /sys/class/power_supply/BAT*; do
echo "$(basename "$b") $(date +%s) $(cat ${b}/power_now) $(cat ${b}/energy_now)" >> $1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment