Update battery plugin to show calculating - OSX
Instantly after removing the charger, I have found that the "AvgTimeToEmpty" value can swing to rediculous values. Apple's current claim is that the max battery life is 12 hours, so any value larger than this is considered a "time is being calculated" value.
Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index 16ad3e6510a6937f528fb120740bc4efcfd592d5..2c00ff141031c06968fc8a1a555a4fd818eaa245 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -30,7 +30,11 @@ if [[ $(uname) == "Darwin" ]] ; then
6 local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
7 if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
8 timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
9- echo "~$((timeremaining / 60)):$((timeremaining % 60))"
10+ if [ $timeremaining -gt 720 ] ; then
11+ echo "::"
12+ else
13+ echo "~$((timeremaining / 60)):$((timeremaining % 60))"
14+ fi
15 else
16 echo "∞"
17 fi