Created
July 13, 2011 12:31
-
-
Save ashtom/1080210 to your computer and use it in GitHub Desktop.
Show a growl notification every minute if battery is below threshold
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 | |
# | |
# Show a growl notification every minute if battery is below threshold. | |
# | |
# Setup: | |
# 1. Install growlnotify | |
# 2. Adjust threshold in line 20 (here 656mAh) | |
# 3. Create line in crontab like this: | |
# * * * * * /path/to/script/battery_low.sh | |
charger=`/usr/sbin/system_profiler SPPowerDataType | grep "Connected:"` | |
if [[ "$charger" == *Yes* ]] | |
then | |
exit | |
fi | |
rem=`/usr/sbin/system_profiler SPPowerDataType | grep -i "Charge remaining" | sed 's/[^0-9]//g'` | |
if [ "$rem" -lt "656" ] | |
then | |
/usr/local/bin/growlnotify -n batteryAlert -p High -m "Battery getting low... ($rem mAh)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment