浏览代码

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.
Chris Wiggins 11 年之前
父节点
当前提交
fdd864bd5b
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      plugins/battery/battery.plugin.zsh

+ 5 - 1
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