diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b440b0a3..9ea12aa7 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -390,20 +390,22 @@ prompt_battery() { # Return if no battery found [[ -z $bat ]] && return - - [[ $(cat $bat/capacity) -gt 100 ]] && local bat_percent=100 || local bat_percent=$(cat $bat/capacity) - [[ $(cat $bat/status) =~ Charging ]] && local connected=true - [[ $(cat $bat/status) =~ Charging && $bat_percent =~ 100 ]] && current_state="charged" - [[ $(cat $bat/status) =~ Charging && $bat_percent -lt 100 ]] && current_state="charging" + local capacity=$(cat $bat/capacity) + local battery_status=$(cat $bat/status) + [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity + [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true if [[ -z $connected ]]; then [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + else + [[ $bat_percent =~ 100 ]] && current_state="charged" + [[ $bat_percent -lt 100 ]] && current_state="charging" fi if [[ -f /usr/bin/acpi ]]; then local time_remaining=$(acpi | awk '{ print $5 }') if [[ $time_remaining =~ rate ]]; then local tstring="..." elif [[ $time_remaining =~ "[[:digit:]]+" ]]; then - local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M)} + local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M 2> /dev/null)} fi fi [[ -n $tstring ]] && local remain=" ($tstring)" @@ -540,6 +542,26 @@ prompt_history() { "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" '%h' } +# Detection for virtualization (systemd based systems only) +prompt_detect_virt() { + if ! command -v systemd-detect-virt;then + return + fi + local virt=$(systemd-detect-virt) + local color="yellow" + if [[ "$virt" == "none" ]]; then + if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then + virt="chroot" + "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt" + fi +} + + prompt_icons_test() { for key in ${(@k)icons}; do # The lower color spectrum in ZSH makes big steps. Choosing |