Created
November 3, 2012 13:42
-
-
Save shtirlic/4007416 to your computer and use it in GitHub Desktop.
Battery status cmd for mac os x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
isFullyCharged=`ioreg -n AppleSmartBattery | grep FullyCharged | awk '{ print $5 }'` | |
timeLeft=`ioreg -n AppleSmartBattery | grep TimeRemaining | awk '{ print $5 }'` | |
isCharging=`ioreg -n AppleSmartBattery | grep IsCharging | awk '{ print $5 }'` | |
if [ $isFullyCharged = "Yes" ] ; then | |
output="Full Charge" | |
else | |
output="$timeLeft mins" | |
if [ $isCharging = "Yes" ] ; then | |
output="$output till charge" | |
else | |
output="$output till drain" | |
fi | |
fi | |
echo $output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment