Read Magic Mouse and Apple Wireless Keyboard Battery percentage

假如想象 提交于 2019-12-01 05:15:23

问题


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!


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!