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'
Magic Mouseの場合は次のとおりです。
ioreg -n "BNBMouseDevice" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'