Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- 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)
- COMPARE=${1:-20}
- if [ -z "$BATT" ]; then
- echo 'No mouse found.'
- exit 0
- fi
- if (( BATT < COMPARE )); then
- osascript -e "display notification \"Mouse battery is at ${BATT}%.\" with title \"Mouse Battery Low\""
- fi
- printf '🖱 %d%%\n' $BATT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement