Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.47k stars 947 forks source link

Battery segment do not respect user defined icons #1245

Closed numered closed 5 years ago

numered commented 5 years ago

Describe Your Issue

Battery segment do not respect user defined icons. issuebattery As seen on the image, the battery segment use a symbol different from the configured one.

Have you tried to debug or fix it?

I tried to use the old variables names but that didn't change anything.

Environment Information

OS: Ubuntu 18.10 ZSH version: 5.5.1 ZSH framework: Oh-My-ZSH P9K installation: Cloning the repo P9K version: Latest next commit at this time (110efcb) Terminal emulator: Tested on Terminator and Ubuntu default terminal

Syphdias commented 5 years ago

Hi @numered,

thanks for the bug report. I think I found the source. I'll open a PR tomorrow. Could you try to delete some lines in $__P9K_DIRECTORY/segments/battery/battery.p9k? I haven't tested this much, but this is what essentially will happen in the PR.

diff --git a/segments/battery/battery.p9k b/segments/battery/battery.p9k
index f6a4d868..c3c81fe5 100644
--- a/segments/battery/battery.p9k
+++ b/segments/battery/battery.p9k
@@ -206,7 +206,6 @@ prompt_battery() {
   # override default icon if we are using battery stages
   local overideIcon="" overideBg="" segment
   declare -i offset
-  if [[ -n "$P9K_BATTERY_STAGES" ]] && [[ -n "$P9K_BATTERY_LEVEL_BACKGROUND" ]]; then
     # override default icon if we are using battery stages
     if [[ -n "$P9K_BATTERY_STAGES" ]]; then
       segment=$(( 100.0 / (${#P9K_BATTERY_STAGES} - 1 ) ))
@@ -223,7 +222,6 @@ prompt_battery() {
       offset=$(( (${bat_percent} / $segment) + 1 ))
       overideBg="$(p9k::background_color ${P9K_BATTERY_LEVEL_BACKGROUND[$offset]})"
     fi
-  fi
   unset offset
   # Draw the prompt_segment
   p9k::prepare_segment "$0" "${(U)current_state}" $1 "$2" $3 "${message}" "" "${overideIcon}" "${overideBg}"
Syphdias commented 5 years ago

@numered Could you check out #1247 to see if it is fixed?

dritter commented 5 years ago

1247 is now merged into next. I close this issue for now. @numered please reopen, if this does not fix your issue.