Skip to content

Instantly share code, notes, and snippets.

@shtirlic
Created November 3, 2012 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shtirlic/4007416 to your computer and use it in GitHub Desktop.
Save shtirlic/4007416 to your computer and use it in GitHub Desktop.
Battery status cmd for mac os x
#!/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