SHARE
TWEET

Untitled

a guest Jun 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top