Skip to content

Instantly share code, notes, and snippets.

@gonzalo123 gonzalo123/
Created Aug 1, 2019

What would you like to do?
#!/usr/bin/env bash
# actual battery level
BATT=`ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i mouse -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2`
# defaults to warn at 20%; accepts other number as 1st argument (useful for testing)
if [ -z "$BATT" ]; then
echo 'No mouse found.'
exit 0
if (( BATT < COMPARE )); then
osascript -e "display notification \"Mouse battery is at ${BATT}%.\" with title \"Mouse Battery Low\""

This comment has been minimized.

Copy link
Owner Author

gonzalo123 commented Aug 1, 2019

*/15 * * * * cd ~ && bash ~/bin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.