Skip to content

Instantly share code, notes, and snippets.

@jmtsantos
Created January 5, 2020 12:44
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 jmtsantos/1c7691fcc24ba70e17fd92dd33a674ec to your computer and use it in GitHub Desktop.
Save jmtsantos/1c7691fcc24ba70e17fd92dd33a674ec to your computer and use it in GitHub Desktop.
Register battery life to file
#!/bin/bash
start_time="$(date -u +%s.%N)"
while true
do
elapsed_time="$(date -u +%s.%N)"
echo "battery:$(cat /sys/class/power_supply/BAT1/capacity) seconds:$(bc <<<"($elapsed_time - $start_time)/60") uptime:$(uptime)"
echo "battery:$(cat /sys/class/power_supply/BAT1/capacity) seconds:$(bc <<<"($elapsed_time - $start_time)/60") uptime:$(uptime)" > uptime.txt
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment