1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-26 14:00:08 +00:00

fixed some edge cases I ran into during usage of the linux segment

This commit is contained in:
rjorgenson 2015-10-18 21:03:47 -07:00
parent ff3f6b8e83
commit 3e828cbaa4

View file

@ -663,7 +663,7 @@ prompt_battery() {
# return if no battery found # return if no battery found
[[ -z $bat ]] && return [[ -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 ]] && local connected=true
[[ $(cat $bat/status) =~ Charging && $bat_percent =~ 100 ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGED}" [[ $(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}" [[ $(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}" [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="%F{$POWERLEVEL9K_BATTERY_LOW_COLOR}" || local conn="%F{$POWERLEVEL9K_BATTERY_DISCONNECTED}"
fi fi
if [[ -f /usr/bin/acpi ]]; then 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 fi
[[ ! -z $tstring ]] && local remain=" ($tstring)" [[ ! -z $tstring ]] && local remain=" ($tstring)"
fi fi