Skip to main content

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).

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

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?


We are using the same Script as @psliequ posted. Works fine!


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.


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)


@emarks 

 

https://community.jamf.com/t5/jamf-pro/big-sur-bluetooth-menu-no-longer-exists/m-p/223158/highlight/true#M211580

 

That should do it for ya


Reply