add new option "POWERLEVEL9K_BATTERY_HIDE_FULL"

Hides the battery segment if percentage hits 100%
pull/22/head
Tim Otlik 7 years ago
parent 7234d52ebd
commit 3c27f14581
No known key found for this signature in database
GPG Key ID: B453C855E9F039C5

@ -488,6 +488,18 @@ prompt_battery() {
fi fi
fi fi
if [[ -v "POWERLEVEL9K_BATTERY_HIDE_FULL" && "$POWERLEVEL9K_BATTERY_HIDE_FULL" == true ]]; then
if [[ "$bat_percent" != "100" ]]; then
if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
local offset=$(( ($bat_percent / $segment) + 1 ))
"$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
else
# Draw the prompt_segment
"$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
fi
fi
else
# override the default color if we are using a color level array # override the default color if we are using a color level array
if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
@ -497,6 +509,7 @@ prompt_battery() {
# Draw the prompt_segment # Draw the prompt_segment
"$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
fi fi
fi
} }
################################################################ ################################################################

Loading…
Cancel
Save