Created
November 17, 2011 00:25
-
-
Save matthewlmcclure/1371983 to your computer and use it in GitHub Desktop.
MacBook Pro Low Battery Notification via Growl
This file contains 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/bash | |
PATH=$PATH:/usr/sbin:/usr/local/bin | |
system_profiler SPPowerDataType | \ | |
grep ' \(Charging\|Charge Remaining\|Full Charge Capacity\)' | \ | |
cut -d ':' -f 2 | \ | |
{ read remaining; | |
read charging; | |
read capacity; | |
if [ "$charging" != "Yes" ] | |
then | |
pctremaining="$(( ${remaining} * 100 / ${capacity} ))"; | |
if [ $pctremaining -lt 10 ] | |
then | |
echo "Low Battery: ${pctremaining}% remaining" | growlnotify -s | |
fi | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment