I want to ask you If anybody know a simple way to access Mouse and Keyboard battery state in Mac OS. There are some API to access this information? Thanks!
For the Keyboard it is:
ioreg -n "IOAppleBluetoothHIDDriver" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'
and for the Magic Mouse it is:
ioreg -n "BNBMouseDevice" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'
来源:https://stackoverflow.com/questions/3547797/read-magic-mouse-and-apple-wireless-keyboard-battery-percentage