Is it possible to tweak the % that I get warning of low battery for my Magic Mouse 2?
I currently only get it at 2% at which point it's very close to dying so I have to stop what I'm doing and plug it in. A reminder about 10-15% would allow me to plug it in the next time I have a natural break.
Best Answer
For those willing to copy and run a bash script and add a cron job, here is a complete solution that is free and current (as of macOS Catalina 10.15.3) and requires no programming (I've done that part for you), just a little system administration:
Save this to a bash script like
~/.mouse-battery-check.sh
:Open up Terminal and make the script executable:
chmod +x ~/.mouse-battery-check.sh
Now you can test that the script sends a desktop notification by running it when your BlueTooth mouse is connected (this tests for battery less than 101%, so it should always send a notification):
To test again with the default setting (20%):
When a BlueTooth mouse is not detected, the script will return, "No mouse found."
Checking Automatically
Now to test periodically and notify you automatically, add a new cron job:
Add an entry like to check every 15 minutes:
(You can again pass the battery percentage as a parameter to the script here.)
Press
Control+X
thenY
thenEnter
to exit the editor and save the cron job.Compatibility
This has been tested on:
Acknowledgements
For battery check, this answer:
adjust battery-warning-level of magic mouse
For notification, this answer:
How can I trigger a Notification Center notification from an AppleScript or shell script?
For cron jobs, this blog:
https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx.html
User sirclesam for compatibility testing.
Enhancement - also check keyboard (and maybe trackpad)
I modified the script above to check both Apple Magic Mouse and Keyboard. With the addition of one word it could check Trackpads, or any other overpriced Apple Magic doo dads, as well. I only have the mouse and keyboard so I started with that. I also changed the default to 10% which still gives me a few days to plug it in.