diff options
author | Chris Wiggins <chris@chriswiggins.co.nz> | 2014-02-17 13:32:24 +1300 |
---|---|---|
committer | Chris Wiggins <chris@chriswiggins.co.nz> | 2014-02-17 13:32:24 +1300 |
commit | fdd864bd5b5444848c492454e025257f3c4fa675 (patch) | |
tree | d8b220254e925581ae885cc35357076efa95248d /plugins | |
parent | 4ce7f0a37f9a13c605225e2a595ad1bdf6171065 (diff) | |
download | zsh-fdd864bd5b5444848c492454e025257f3c4fa675.tar.gz zsh-fdd864bd5b5444848c492454e025257f3c4fa675.tar.bz2 zsh-fdd864bd5b5444848c492454e025257f3c4fa675.zip |
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.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/battery/battery.plugin.zsh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 16ad3e651..2c00ff141 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -30,7 +30,11 @@ if [[ $(uname) == "Darwin" ]] ; then local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') - echo "~$((timeremaining / 60)):$((timeremaining % 60))" + if [ $timeremaining -gt 720 ] ; then + echo "::" + else + echo "~$((timeremaining / 60)):$((timeremaining % 60))" + fi else echo "∞" fi |