App offering audible alarm for low battery on Mavericks?

Solution 1:

You could write a short script and run it via cron every couple of minutes.

pmset -g batt

Running the above will show your current battery usage. You can then parse it out and you can make it alert you with something like:

say "low battery power"

That will speak out "low battery power. Or to make it beep:

printf "\a"

I have a desktop, so can't see the pmset output, a quick google shows something like this would do it:

if [[ `pmset -g batt | awk -F'[^0-9]*' '{ print $3 }'` -lt 10 ]];then say "Battery low";fi

You can put that into a cron to run every 5 mins or so.

To add this to cron to run every 5 minutes, do:

crontab -e

and type in a line that looks like this:

*/5  *  *  *  *  if [[ `pmset -g batt | awk -F'[^0-9]*' '{ print $3 }'` -lt 10 ]];then say "Battery low";fi

Then save and exit. The crontab editor will be whichever is set as your default editor in $EDITOR. For me that vim, default OSX it's nano.

crontab -l

That lists out your crontab. For more info see: enter link description here

To use launchd, you'd be better off putting that into a shell script, then putting a launchd plist file in your ~/Library/LaunchDaemons folder. That's somewhat out of scope of this answer, Lingon is a great tool to control LaunchD files. See LaunchD for more information. You shell script would be be the same command as used above, with

#!/bin/sh

as the first line. Save it somewhere, make LaunchD run it.