diff options
author | rjorgenson <rjorgenson@gmail.com> | 2015-10-19 07:03:47 +0300 |
---|---|---|
committer | rjorgenson <rjorgenson@gmail.com> | 2015-10-19 07:03:47 +0300 |
commit | 3e828cbaa47227fde34624229018d90d4651a586 (patch) | |
tree | cf2da93d0db70841142b99b0fb162d151dab5506 /powerlevel9k.zsh-theme | |
parent | ff3f6b8e833946a8e98352ceb15e8eb5682e2b69 (diff) |
fixed some edge cases I ran into during usage of the linux segment
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bb24e60a..bc37de31 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -663,7 +663,7 @@ prompt_battery() { # return if no battery found [[ -z $bat ]] && return - local bat_percent=$(cat $bat/capacity) + [[ $(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 ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGED}" [[ $(cat $bat/status) =~ Charging && $bat_percent -lt 100 ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGING}" @@ -671,7 +671,12 @@ prompt_battery() { [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="%F{$POWERLEVEL9K_BATTERY_LOW_COLOR}" || local conn="%F{$POWERLEVEL9K_BATTERY_DISCONNECTED}" fi if [[ -f /usr/bin/acpi ]]; then - [[ $(acpi | awk '{ print $5 }') =~ rate ]] && local tstring="..." || local tstring=${(f)$(date -u -d @$(acpi | awk '{ print $5 }' | sed s/://g) +%k:%M)} + 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 | sed s/://g) +%k:%M)} + fi fi [[ ! -z $tstring ]] && local remain=" ($tstring)" fi |