diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2018-06-07 02:25:24 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2018-06-07 02:25:24 +0300 |
commit | db7638056352caae9ae738259ac0e636f918e0c3 (patch) | |
tree | 681d03ad2278b9c660beaa0a35c230c1a8a66c28 | |
parent | 3456af3aac62dcdbcf117b4f73276fac4a3c82fd (diff) | |
parent | 7ab9cb150ecaef0d5fe906b9ef490b4e7c4f097d (diff) |
Merge remote-tracking branch 'sambadevi/feature/hide-battery-segment' into staging_065
-rwxr-xr-x | powerlevel9k.zsh-theme | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index a6e0ac2a..c087cfbf 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -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 } ################################################################ @@ -637,14 +641,14 @@ prompt_user() { "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "ROOT_ICON" ) - elif sudo -n true 2>/dev/null; then - user_state=( - "STATE" "SUDO" - "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "SUDO_ICON" - ) + elif sudo -n true 2>/dev/null; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SUDO_ICON" + ) else user_state=( "STATE" "DEFAULT" |