Omarchy

How-To: See Your Linux Laptop’s Battery History and Health From the Terminal With upower

Leave a comment

Omarchy 4.6 RC2’s power panel now charts the last 24 hours of battery. If you’re on stable, or on any Linux laptop, upower has been quietly keeping a history the whole time. All read-only.

1. Find your battery

upower -e | grep -i bat

2. Current state and health

upower -i "$(upower -e | grep -i bat | head -1)"

Compare energy-full to energy-full-design. That ratio is your battery health, and capacity shows it as a percentage. Also check energy-rate to see how many watts you’re pulling right now.

3. Cycle count straight from the kernel

cat /sys/class/power_supply/BAT*/cycle_count

4. The history upower already logged

ls /var/lib/upower/
tail -n 24 /var/lib/upower/history-charge-*.dat

Each line is a Unix timestamp, a percentage and a state. Make it readable (needs gawk):

tail -n 48 /var/lib/upower/history-charge-*.dat | \
  gawk '{ print strftime("%m-%d %H:%M", $1), $2 "%", $3 }' 

The history-rate-*.dat file logs discharge rate in watts the same way, which is how you catch the app that ate your afternoon.

5. Watch it live

upower --monitor-detail

Ctrl+C to stop. For drain while the lid is closed, my sleep-drain how-to covers that side.

God Bless, and Happy hacking!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.