aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-07-20 16:40:15 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-07-20 16:40:15 +0300
commitfa0c4478174de86c76ba7c45b4662c2d3cdfc1e6 (patch)
tree075988d5cb2207f58e1f9645c71a5c6ab5ceb5e2 /internal/p10k.zsh
parent38c4df2d5198344eb6a410931c90e2d26182b2d5 (diff)
don't use state CHARGED when the battery is at 100% and discharging; use DISCONNECTED instead
Diffstat (limited to 'internal/p10k.zsh')
-rwxr-xr-xinternal/p10k.zsh24
1 files changed, 12 insertions, 12 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index ade3f9c4..39820ed7 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