Extension Attribute - macOS Apple Silicon Current Battery Level

adavenport321
New Contributor II

Posting this for anyone that wants to get battery level on Apple Silicon Mac and use it for EA

#!/bin/sh
# Used to get battery presentage on a Mac.
# Works on macOS11 and Apple Silicon
battery=$(pmset -g batt | grep -o '[0-9]*%; [a-z]*' | sed 's/%//')
echo "<result>${battery%;*}</result>"
0 REPLIES 0