One of the worst things about the Apple Magic mouse is the fact that the OS doesn't give you any kind of low battery alert until it hits 2% battery...
For further actions, you may consider blocking this person and/or reporting abuse
I too was getting quite annoyed only getting a battery-low warning at 2%. This script is a great workaround.
The only thing I had to add was the path to ioreg as the cron job could not find it
PATH=/usr/sbin:$PATHWhere does this code go?
In the mouseCheck.sh, just before the 'BATT=..' command
Thank you for posting this! So annoying Apple hasn't built in their own warning. One typo though: Hit CMD + D to return to terminal prompt should be CTR + D (control).
This script is absolutely beautiful, thank-you so much!
Here are some recommendations:
If you have multiple mice or keyboards, consider only the one having the lowest battery level:
BATT=ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i mouse -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2 | sort -n | head -1KEY_BATT=ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i "Magic Keyboard" -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2 | sort -n | head -1If you would like to play a sound (From /System/Library/Sounds) along with the notification:
osascript -e "display notification \"Mouse battery is at ${BATT}%.\" with title \"Mouse Battery Low\" sound name \"Bottle\""osascript -e "display notification \"Keyboard battery is at ${KEY_BATT}%.\" with title \"Keyboard Battery Low\" sound name \"Bottle\""You can also check if the mouse is charging with the following:
When I save the crontab file, it's tacking on this weird extension at the end of the file. See screenshot attached.
That's normal. You are not editing the crontab file directly. Once you save this tmp file and it contains no errors, it will overwrite the actual cron file (in /var/at/tabs/)
Using display alert instead of display notification may be more appropriate