aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-10-11 11:33:49 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-10-11 11:33:49 +0300
commit5b9e75be3a6fc4a866ca0289b8697c71259045f2 (patch)
tree35e4aa754bebb9aae215459856f457032d53456d /internal/p10k.zsh
parent0c59d87f0853b42cf075e4dc7b176ad3c49fe1c0 (diff)
add POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND; fixes #256
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index f1aaa2b4..0f63b76c 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -1115,7 +1115,14 @@ prompt_battery() {
bg=$_POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[idx]
fi
- _p9k_prompt_segment $0_$state "$bg" "$_p9k_battery_states[$state]" $icon 0 '' $msg
+ local fg=$_p9k_battery_states[$state]
+ if (( $#_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND )); then
+ local -i idx=$#_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND
+ (( bat_percent < 100 )) && idx=$((bat_percent * $#_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND / 100 + 1))
+ fg=$_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND[idx]
+ fi
+
+ _p9k_prompt_segment $0_$state "$bg" "$fg" $icon 0 '' $msg
}
################################################################
@@ -3893,6 +3900,7 @@ _p9k_init_params() {
_p9k_declare -i POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10
_p9k_declare -i POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD 999
_p9k_declare -a POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND --
+ _p9k_declare -a POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND --
_p9k_declare -b POWERLEVEL9K_BATTERY_VERBOSE 1
if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then
_p9k_declare -e POWERLEVEL9K_BATTERY_STAGES