From fa0c4478174de86c76ba7c45b4662c2d3cdfc1e6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 20 Jul 2019 15:40:15 +0200 Subject: [PATCH] don't use state CHARGED when the battery is at 100% and discharging; use DISCONNECTED instead --- internal/p10k.zsh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index ade3f9c..39820ed 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -729,13 +729,13 @@ prompt_battery() { case "${${(s:; :)raw_data}[2]}" in 'charging'|'finishing charge'|'AC attached') - state=charging + state=CHARGING ;; 'discharging') - (( bat_percent < POWERLEVEL9K_BATTERY_LOW_THRESHOLD )) && state=low || state=disconnected + (( bat_percent < POWERLEVEL9K_BATTERY_LOW_THRESHOLD )) && state=LOW || state=DISCONNECTED ;; *) - state=charged + state=CHARGED remain='' ;; esac @@ -772,15 +772,15 @@ prompt_battery() { bat_percent=$(( 100. * energy_now / energy_full + 0.5 )) (( bat_percent > 100 )) && bat_percent=100 - if (( is_full || bat_percent == 100 )); then - state=charged + if (( is_full || (bat_percent == 100 && is_charching) )); then + state=CHARGED else if (( is_charching )); then - state=charging + state=CHARGING elif (( bat_percent < POWERLEVEL9K_BATTERY_LOW_THRESHOLD )); then - state=low + state=LOW else - state=disconnected + state=DISCONNECTED fi if (( power_now > 0 )); then @@ -3344,10 +3344,10 @@ _p9k_init() { fi typeset -gA _P9K_BATTERY_STATES=( - 'low' 'red' - 'charging' 'yellow' - 'charged' 'green' - 'disconnected' "$DEFAULT_COLOR_INVERTED" + 'LOW' 'red' + 'CHARGING' 'yellow' + 'CHARGED' 'green' + 'DISCONNECTED' "$DEFAULT_COLOR_INVERTED" ) local -i i=0