I'm weird. We all have our weird habits and quirks. Luckily for me, mine only involves my the battery in my macbook computer.
Are you worried about keeping your devices' batteries healthy and keeping a charge? With every device I have owned, battery health has degraded noticeably over time, likely due to my poor charging habits.
I'll be the first to admit, I am no electrochemist. I might be (and likely am) askew, and what I am about to show you may have absolutely no effect on battery performance. But, I like to believe it does :)
I wanted a way to get a notification when my battery reaches 40% and 80%. That's my target range. So I wrote a script to do it (I have no life). It is written in AppleScript, and uses a fancy-pants notification card to display a message when it's time to charge or unplug the charge cable. The script relies on Apple's task scheduler launchd
, and by following these instructions, the script will run automatically after login.
First, you will need to download the two files below BatteryStatusNotification.scpt
and battery.monitor.plist
. Make sure you edit the plist
file to point to the correct script file.
If you want to run the script once, just run osascript BatteryStatusNotification.scpt
. This is fine, but won't automatically run the script on login. To do this, copy the plist
file battery.monitor.plist
to ~/Library/LaunchAgents/
. I recommend placing the script under ~/Applications
.
Test this out and let me know what you think! You can also easily adjust the boundaries, or modify the script to suit your needs.
Stack Exchange - How to run custom AppleScript in Background
@brandon1024 Yes, thanks much! I was about to embark on something similar and you saved me a bunch of work. I was just interested in something to monitor charge/discharge state and alert (scream noise...) when it reached ~80% for devices going into storage for several months. So I cobbled together this as an app:
BTW, I found that
awk
ing thepmset
result wasn't strictly necessary as AS'scontains
will simply search the contents of the string - probably a toss up as far as code efficiency goes..