|
|
Notify yourself periodically using Growl
I had to do something like this to let myself know when my battery's getting drained.
I've taken my battery icon out of the menu bar, and put status on my desktop, using GeekTool. (Details here, in the comments. Not the point.)
The problem is, my 20% battery power warnings no longer show up. So I used growlnotify and a launchd agent to alert myself when things get low.
Using launchd, I run this shell script (which I've called batteryAlert.sh and placed in /usr/local/bin) every 300 seconds:
#!/bin/bash # get battery charge (in mA, I think) rem=`system_profiler SPPowerDataType | grep "Remaining" | cut -c 33-36` # is charge less than 800 (out of a possible 4300 or so)? if [ "$rem" -lt "800" ] then # tell me about it using growl /usr/local/bin/growlnotify -n batteryAlert -p High "Battery getting low..." fiIf you wanted an alternative to using growlnotify, try going with AppleScript, replacing the line containing the growlnotify call with the following: osascript -e 'tell application "Finder"' -e "activate" -e "display dialog "Battery getting low..."" -e 'end tell'This has the disadvantage of requiring you to click "OK" to dismiss the dialog; maybe there's a better way...
Notify yourself periodically using Growl
If you want to dismisss the dialog automatically, just change the command to this:
display dialog "Battery getting low..." buttons {"OK"} giving up after 2 the "buttons" part is optional, it makes the dialog showing only the OK button the "giving up" part makes the dialog dismiss itself after x seconds (2 in the example).
Low battery warning AppleScript
Thanks for the script! Here it is updated for Snow Leopard with the AppleScript typo fixed as well:
#!/bin/bash rem=`system_profiler SPPowerDataType | grep "Charge remaining" | sed 's/[^0-9]//g'` if [ "$rem" -lt "800" ] then osascript -e 'tell application "Finder"' -e "activate" -e 'display dialog "Low battery warning"' -e 'end tell' fi |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.13 seconds |
|