How to reliably determine battery health from terminal?

Every time my laptop’s battery got fully discharged (out of negligence), the battery condition is 90%. I check the battery’s condition using inxi -B. But after a full recharge, it’s back to 102%, not sure why it’s not 100%. I know full discharge must be prevented since it can shorten the battery’s lifespan, that’s why I need to know the actual condition of the battery so that I know when to replace it. So, how do I accurately determine by battery health via the terminal?

Inxi is probably doing already enough. The condition is something the battery has to report itself, and some firmwares are just not reliable in that matter.

You can try some alternative methods
https://www.cyberciti.biz/faq/check-see-laptop-battery-health-in-linux-command/

1 Like

upower also gives the same number for battery condition as inxi. While acpi does not output any battery health status, although it still output some strange message:

Battery 1: Charging, 97%, charging at zero rate - will never fully charge.

It says the charging rate is zero, so will never fully charge, although in reality my battery is still charging. That percentage is actually increasing.

You can snoop the script from [root tip] [Utility Script] Charger Notifier - battery state to get an idea.

If by battery health you mean compared to factory state you can use upower

upower -i /org/freedesktop/UPower/devices/battery_BAT0

Look at the battery properties

Example

 $ upower -i /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               Sunwoda
  model:                5B11M90050
  serial:               823
  power supply:         yes
  updated:              2025-03-09T10:41:44 CET (17 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              20,05 Wh
    energy-empty:        0 Wh
    energy-full:         51,63 Wh
    energy-full-design:  54,7 Wh
    energy-rate:         6,511 W
    voltage:             15,074 V
    charge-cycles:       43
    time to empty:       3,1 hours
    percentage:          38%
    capacity:            94,3876%
    technology:          lithium-polymer
    charge-start-threshold:        75%
    charge-end-threshold:          80%
    charge-threshold-supported:    yes
    icon-name:          'battery-good-symbolic'
  History (charge):
    1741513274  38,000  discharging
  History (rate):
    1741513304  6,511   discharging
    1741513274  6,536   discharging
    1741513244  7,176   discharging
    1741513214  8,279   discharging

I have only skimmed through the mentioned link, does it allow me to set notifications at more than one battery percentage level? I believe the default manjaro setting already sets a notification once the level enters the “critical level”, but I often miss the notification.

About upower, in my case it outputs the same battery health parameter (capacity in the output of upower) as inxi. But should upower generally be more accurate than inxi?

The battery provides the information displayed by upower - so if inxi gets the information from upower it will be the same.

Upower reads from the /sys tree - in the end data comes from the same source.

The script is designed to provide a notification for plug / unplug charger within a user defined range.

The reason the script exist is because only a few hardware vendors support charge threshold levels thus a manual intevention may be required.

The properties energy-full and energy-full-design in a percent equation will give you capacity

In my example

...
    energy-full:         51,63 Wh
    energy-full-design:  54,7 Wh
...
    capacity:            94,3876%
...
51.63 *100 / 54,7 ≃ 94%
2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.