Commit fdd864bd authored by Chris Wiggins's avatar Chris Wiggins
Browse files

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.
parent 4ce7f0a3
...@@ -30,7 +30,11 @@ if [[ $(uname) == "Darwin" ]] ; then ...@@ -30,7 +30,11 @@ if [[ $(uname) == "Darwin" ]] ; then
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
if [ $timeremaining -gt 720 ] ; then
echo "::"
else
echo "~$((timeremaining / 60)):$((timeremaining % 60))" echo "~$((timeremaining / 60)):$((timeremaining % 60))"
fi
else else
echo "∞" echo "∞"
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment