For limiting a MacBook battery's charge to prolong its life I find bclm
a lot more straightforward than AlDente.
sudo bclm write 81
keeps the hardware battery percentage at 80% on both my MacBooks (I haven't found a reason to use persist
, yet).
I would often set the bclm to 100 some period of time before taking one to a coffee shop. With this script I don't have to remember to reset it.
I currently combine it with telling DropBox to quit, which seems to smooth out issues with the machine orienting itself to the coffee shop's WiFi while waking up.
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
echo 'script must be run by root' >&2
exit 1
fi
echo "starting full charge cycle.."
bclm-cc || exit 1
echo "telling dropbox to quit.."
osascript -e 'tell application "Dropbox" to quit'
echo "undock!, undock!"
Thanks to a tip from this very informative gist, I now have passwordless sudo set up for this script.
sudo visudo
..opens /etc/sudoers
in vim. I added this to the bottom:
my-username ALL=(ALL) NOPASSWD: /Users/my-username/.bin/bclm-cc
Now sudo bclm-cc
no longer requires a password.