Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. BATT=$(ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i mouse -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2)
  4.  
  5. # defaults to warn at 20%; accepts other number as 1st argument (useful for testing)
  6. COMPARE=${1:-20}
  7.  
  8. if [ -z "$BATT" ]; then
  9. echo 'No mouse found.'
  10. exit 0
  11. fi
  12.  
  13. if (( BATT < COMPARE )); then
  14. osascript -e "display notification \"Mouse battery is at ${BATT}%.\" with title \"Mouse Battery Low\""
  15. fi
  16.  
  17. printf '🖱 %d%%\n' $BATT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement