summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2016-12-21 01:51:59 +0300
committerGitHub <noreply@github.com>2016-12-21 01:51:59 +0300
commit55b43d819dd61ff0c8719e935284435e0d20bdfc (patch)
treed099014d706dde4fd08c5cfa18a7d86f9d1947fc
parent1ff9da64d974265ce2f22bd1da4a47d0b8f7ca90 (diff)
parentb37090073c5ad491d7f70803e7f06168471b3148 (diff)
Merge pull request #348 from DeanF/master
Fixed an issue where full battery registers as disconnected
-rwxr-xr-xpowerlevel9k.zsh-theme14
1 files changed, 8 insertions, 6 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index c06d1286..d56e46f4 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -397,20 +397,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)"