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 <= 4 then
tell application “iTunes”
pause
end tell
set volume 100
do shell script “say -v “Zarvox” “LOW BATTERY” “
if Pct <= 3 then
beep 5
do shell script “say -v “Zarvox” “PLUG ME IN NOW””
end if
end if
end if

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:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>batteryAlert</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/etc/batteryScript.applescript</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Battery Alert</string>
<key>StartInterval</key>
<integer>30</integer>
</dict>
</plist>

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]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


One response to “Give Your Mac A More Attention-Grabbing ‘Low Battery’ Warning”

Leave a Reply