mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-18 13:41:56 +00:00
Merge remote-tracking branch 'sambadevi/feature/hide-battery-segment' into staging_065
This commit is contained in:
commit
db76380563
1 changed files with 21 additions and 17 deletions
|
@ -487,16 +487,20 @@ prompt_battery() {
|
|||
[[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1}
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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
|
||||
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"
|
||||
# return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal
|
||||
if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# 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
|
||||
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
|
||||
}
|
||||
|
||||
################################################################
|
||||
|
|
Loading…
Reference in a new issue