Skip to content

Commit

Permalink
Hide battery symbol when not charging
Browse files Browse the repository at this point in the history
When charging thresholds for battery health are set (e.g. on ThinkPads,
the default is never to charge when battery level is at least 96%) it is
common for the battery to be neither charging nor discharging, while not
having 100% charge. Which lead to the green charging symbol being always
displayed.

Example output, in given ThinkPad scenario:
```
$ sudo tlp-stat --battery
--- TLP 1.2.2 --------------------------------------------

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = inactive (no kernel support)
tpacpi-bat = active (thresholds, recalibrate)
tp-smapi   = inactive (ThinkPad not supported)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer                   = SMP
/sys/class/power_supply/BAT0/model_name                     = LNV-45N1
/sys/class/power_supply/BAT0/cycle_count                    = (not supported)
/sys/class/power_supply/BAT0/energy_full_design             =  56250 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  43670 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  43610 [mWh]
/sys/class/power_supply/BAT0/power_now                      =      0 [mW]
/sys/class/power_supply/BAT0/status                         = Not charging (threshold effective)

tpacpi-bat.BAT0.startThreshold                              =     96 [%]
tpacpi-bat.BAT0.stopThreshold                               =    100 [%]
tpacpi-bat.BAT0.forceDischarge                              =      0

Charge                                                      =   99.9 [%]
Capacity                                                    =   77.6 [%]

$ acpi
Battery 0: Not charging, 99%
```
  • Loading branch information
ste-fan authored and dolmen committed Oct 16, 2019
1 parent 77f4b2c commit 5f4aeec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions liquidprompt
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,9 @@ case "$LP_OS" in
if [[ "$acpi" == *"Discharging"* ]]; then
# under => 0, above => 1
return $(( bat > LP_BATTERY_THRESHOLD ))
# not charging
elif [[ "$acpi" == *"Not charging"* ]]; then
return 4
# charging
else
# under => 2, above => 3
Expand Down

0 comments on commit 5f4aeec

Please sign in to comment.