I have seen many post here/on SO and many docs on Apple's website about reading the battery level on iOS, but what's the best way to do this on a MacBook? In the past the only way I've found to do this is with a time-consuming bash command piped to grep, which seems very inefficient. (as seen and adapted from, although I can't locate the original source I read, here and here) Is there a better way to do this programmatically? I've also seen this, but that only appears to have an Obj-C version. Is there any way to do this in Swift?
EDIT
There's actually a better way that doesn't take any significant time (ioreg -l -w0 | grep Capacity shows current charge and maximum capacity), but it is still a seemingly unneeded bash script.
ioreg) Since this is API/SDK related, ping be if people vote to close it - we can get it to SO in that case... – bmike Nov 15 '20 at 23:18