MacOS – App offering audible alarm for low battery on Mavericks

batterymacossoftware-recommendation

I installed the update to Mavericks a few days ago, and while it's mostly been great there is no longer a sound that goes with the low battery warning. I have several programs which suppress the visual notifications, which makes for very unpleasant interruptions when the machine goes into standby.

I contacted Apple support about it and they said that there is no way to add a sound to the notification using settings available in the operating system. They suggested I use a 3rd party app, but although I have found some which offer low battery pop up windows, I'm having trouble finding any offering an audible alert.

Best Answer

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.