don't use state CHARGED when the battery is at 100% and discharging; use DISCONNECTED instead

pull/145/head
romkatv 5 years ago
parent 38c4df2d51
commit fa0c447817

@ -729,13 +729,13 @@ prompt_battery() {
case "${${(s:; :)raw_data}[2]}" in case "${${(s:; :)raw_data}[2]}" in
'charging'|'finishing charge'|'AC attached') 'charging'|'finishing charge'|'AC attached')
state=charging state=CHARGING
;; ;;
'discharging') '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='' remain=''
;; ;;
esac esac
@ -772,15 +772,15 @@ prompt_battery() {
bat_percent=$(( 100. * energy_now / energy_full + 0.5 )) bat_percent=$(( 100. * energy_now / energy_full + 0.5 ))
(( bat_percent > 100 )) && bat_percent=100 (( bat_percent > 100 )) && bat_percent=100
if (( is_full || bat_percent == 100 )); then if (( is_full || (bat_percent == 100 && is_charching) )); then
state=charged state=CHARGED
else else
if (( is_charching )); then if (( is_charching )); then
state=charging state=CHARGING
elif (( bat_percent < POWERLEVEL9K_BATTERY_LOW_THRESHOLD )); then elif (( bat_percent < POWERLEVEL9K_BATTERY_LOW_THRESHOLD )); then
state=low state=LOW
else else
state=disconnected state=DISCONNECTED
fi fi
if (( power_now > 0 )); then if (( power_now > 0 )); then
@ -3344,10 +3344,10 @@ _p9k_init() {
fi fi
typeset -gA _P9K_BATTERY_STATES=( typeset -gA _P9K_BATTERY_STATES=(
'low' 'red' 'LOW' 'red'
'charging' 'yellow' 'CHARGING' 'yellow'
'charged' 'green' 'CHARGED' 'green'
'disconnected' "$DEFAULT_COLOR_INVERTED" 'DISCONNECTED' "$DEFAULT_COLOR_INVERTED"
) )
local -i i=0 local -i i=0

Loading…
Cancel
Save