Posted on 08-09-2016 01:46 AM
Is there a way to enable "show battery percentage" for MacBooks using a policy and/or a script?
I googled and found ways to display the battery percentage actually within Terminal, but I couldn't see a way to enable it to always be displayed on the menu bar?
The Energy Saver profile settings don't contain a setting for this.
Thanks,
Dan Jackson (Lead ITServices Technician).
Posted on 08-09-2016 02:41 AM
Something like this, set either as a login policy or at the next check-in;
#!/bin/sh
currentUser=`ls -l /dev/console | cut -d " " -f4`
sudo -u $currentUser defaults write com.apple.menuextra.battery ShowPercent YES
sudo -u $currentUser killall SystemUIServer
Posted on 09-19-2019 07:28 PM
Trying to deploy this via a config profile and it doesn't appear to work.
I assume it has something to do with it being a per user setting as oppose to a global setting?
Am I just better off to deploy this via a script on login for each user?
Posted on 09-20-2019 12:52 AM
We are using the same Script as @psliequ posted. Works fine!
Posted on 10-15-2019 09:09 AM
This no longer appears to be working I am trying to incorporate VPN Icon in here as well but my syntax must be be wrong somewhere.
#!/bin/sh
user=$(stat -f %Su /dev/console);
sudo -u $user open "/System/Library/CoreServices/Menu Extras/vpn.menu"
sudo -u $user defaults write com.apple.menuextra.battery -ShowPercent YES
sudo -u $user killall SystemUIServer
Some assistance would be most appreciated, as I am learning here.
Posted on 06-17-2021 07:46 AM
If anyone has an update on this that would be great! It does not seem to be working anymore. (macOS Big Sur 11.4, M1 MacBook Air)
Posted on 11-05-2021 11:34 AM