Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想问你是否有人知道在 Mac OS 中访问鼠标和键盘电池状态的简单方法。有一些 API 可以访问这些信息吗?谢谢!
对于键盘,它是:
ioreg -n "IOAppleBluetoothHIDDriver" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'
对于魔术鼠标,它是:
ioreg -n "BNBMouseDevice" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'