I'm new to mac and everything around, I just want to know if I can code a sort of plug-in to show the batterie of the magic mouse, in the menu bar.
What is the type of template i have to choose in Xcode to realize my idea.
I'm new to mac and everything around, I just want to know if I can code a sort of plug-in to show the batterie of the magic mouse, in the menu bar.
What is the type of template i have to choose in Xcode to realize my idea.
On
So this answer is more a shell-first answer, but you can execute shell commands in ObjectiveC/Swift too.
You can get the percentage of your bluetooth devices pretty easy with this shell command:
ioreg -l | grep BatteryPercent
With a little bit of regex you should be able to get the number:
Regex 1: https://regexr.com/3ouu3
Regex 2: https://regexr.com/3ouu6
Or as a complete shell solution:
ioreg -c BNBMouseDevice |grep '"BatteryPercent" =' | tr -dc '0-9'
And the same for the Magic Keyboard:
ioreg -c AppleBluetoothHIDKeyboard |grep '"BatteryPercent" =' | tr -dc '0-9'
So know I have differents informations I would like to know to insert the BatteryPercent from the IORegistery explorator in my code ;)
I have the Bundle Identifier from IORegistery :com.apple.driver.AppleBluetoothMultitouch