取得方法
次のコマンドを実行することでバッテリー残量を取得できます。
ioreg -arl -c AppleDeviceManagementHIDEventService -k BatteryPercent -d 1 > /tmp/hid_info.plist && /usr/libexec/PlistBuddy -c "Print 0:Product" -c "Print 0:BatteryPercent" /tmp/hid_info.plist 2>/dev/null
実行すると次のように出力されます。
$ ioreg -arl -c AppleDeviceManagementHIDEventService -k BatteryPercent -d 1 > /tmp/hid_info.plist && /usr/libexec/PlistBuddy -c "Print 0:Product" -c "Print 0:BatteryPercent" /tmp/hid_info.plist 2>/dev/null
Magic Trackpad
15