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.
Paste the following contents into the AppleScript Editor and save the script to: /etc/batteryScript.applescript. [crarko adds: You may first need to save the file to your Desktop and then copy it to the hidden /etc directory after using the Finder 'Go to Folder...' command.]
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
sudo chmod +rx /etc/batteryScript.applescript
Create a new text file and paste the following contents into it. Save this file as ~/Library/LaunchAgents/batteryAlert.plist.
<?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>
[crarko adds: I haven't tested this one. Zarvox? That will get your attention, all right.]