Give Your Mac A More Attention-Grabbing ‘Low Battery’ Warning

Give Your Mac A More Attention-Grabbing ‘Low Battery’ Warning

If you too easily ignore the tiny “low battery” warning on your Mac, weblog Mac OS X Hints shares a script to make it warn you repeatedly and out loud that your battery is getting low.

Mac OS X Hints reader Toggi3 explains the inspiration for the script:

I once owned a ThinkPad T60 series and when the battery in it became critically low it would beep wildly and make its low battery status very well known (impossible to ignore) and forced me to do something about it.

I am distracted easily, and when focused on other things, I tend to completely ignore that little warning window and the tiny alert noise that comes with it that Mac OS X presents me when my battery is low. I have created an AppleScript and developed a method to get a similar effect on my Mac laptop.

Essentially, after installing this script, your Mac will beep and say in a loud, robotic voice “Low battery. Plug me in now.” over and over again until you connect it to the wall. Not unlike an alarm clock that you set on the other side of the room, it’s pretty impossible to ignore.

To set it up, just copy the code below and paste it into AppleScript Editor. Save the script as batteryScript.applescript on your desktop.

set Cap to (do shell script “ioreg -w0 -l | grep ExternalChargeCapable”) tell Cap to set {wallPower} to {last word of paragraph 1} if wallPower = “Yes” then return 0 else set Cap to (do shell script “ioreg -wO -l | grep Capacity”) tell Cap to set {Available, Max} to {last word of paragraph 2, last word of paragraph 1} set Pct to round (100 * Available / Max)

if Pct

Open up the Finder and hit Go > Go to Folder and type in /etc/. Drag your new script into that folder, and type in your password when prompted. Then, open up a Terminal and type:

sudo chmod +rx /etc/batteryScript.applescript

This will make it executable. Lastly, open up TextEdit and paste the following code in:

KeepAliveLabelbatteryAlertLowPriorityIOProgramArguments/usr/bin/osascript/etc/batteryScript.applescriptRunAtLoadServiceDescriptionBattery AlertStartInterval30

Go to Format > Make Plain Text, and then save the file as ~/Library/LaunchAgents/batteryAlert.plist. After a reboot, your computer will have the new battery warning installed. Check out the video to see a demonstration.

Make a more obvious low battery warning [Mac OS X Hints]


Log in to comment on this story!