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

Merge pull request #348 from DeanF/master

Fixed an issue where full battery registers as disconnected
This commit is contained in:
Ben Hilburn 2016-12-20 17:51:59 -05:00 committed by GitHub
commit 55b43d819d

View file

@ -397,20 +397,22 @@ prompt_battery() {
# Return if no battery found # Return if no battery found
[[ -z $bat ]] && return [[ -z $bat ]] && return
local capacity=$(cat $bat/capacity)
[[ $(cat $bat/capacity) -gt 100 ]] && local bat_percent=100 || local bat_percent=$(cat $bat/capacity) local battery_status=$(cat $bat/status)
[[ $(cat $bat/status) =~ Charging ]] && local connected=true [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity
[[ $(cat $bat/status) =~ Charging && $bat_percent =~ 100 ]] && current_state="charged" [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true
[[ $(cat $bat/status) =~ Charging && $bat_percent -lt 100 ]] && current_state="charging"
if [[ -z $connected ]]; then if [[ -z $connected ]]; then
[[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" [[ $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 fi
if [[ -f /usr/bin/acpi ]]; then if [[ -f /usr/bin/acpi ]]; then
local time_remaining=$(acpi | awk '{ print $5 }') local time_remaining=$(acpi | awk '{ print $5 }')
if [[ $time_remaining =~ rate ]]; then if [[ $time_remaining =~ rate ]]; then
local tstring="..." local tstring="..."
elif [[ $time_remaining =~ "[:digit:]+" ]]; then 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
fi fi
[[ -n $tstring ]] && local remain=" ($tstring)" [[ -n $tstring ]] && local remain=" ($tstring)"