mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +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}
|
[[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal
|
||||||
# override the default color if we are using a color level array
|
if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
|
||||||
if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
|
return
|
||||||
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
|
||||||
|
|
||||||
|
# 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
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
@ -637,14 +641,14 @@ prompt_user() {
|
||||||
"FOREGROUND_COLOR" "yellow"
|
"FOREGROUND_COLOR" "yellow"
|
||||||
"VISUAL_IDENTIFIER" "ROOT_ICON"
|
"VISUAL_IDENTIFIER" "ROOT_ICON"
|
||||||
)
|
)
|
||||||
elif sudo -n true 2>/dev/null; then
|
elif sudo -n true 2>/dev/null; then
|
||||||
user_state=(
|
user_state=(
|
||||||
"STATE" "SUDO"
|
"STATE" "SUDO"
|
||||||
"CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
|
"CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
|
||||||
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
|
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
|
||||||
"FOREGROUND_COLOR" "yellow"
|
"FOREGROUND_COLOR" "yellow"
|
||||||
"VISUAL_IDENTIFIER" "SUDO_ICON"
|
"VISUAL_IDENTIFIER" "SUDO_ICON"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
user_state=(
|
user_state=(
|
||||||
"STATE" "DEFAULT"
|
"STATE" "DEFAULT"
|
||||||
|
|
Loading…
Reference in a new issue