Skip to main content
Question

Enabling "show battery percentage" via script or policy?

  • August 9, 2016
  • 6 replies
  • 76 views

Forum|alt.badge.img+10

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

6 replies

Forum|alt.badge.img+13
  • Contributor
  • August 9, 2016

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

Forum|alt.badge.img+5
  • Contributor
  • September 20, 2019

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?


Forum|alt.badge.img+3
  • New Contributor
  • September 20, 2019

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


Forum|alt.badge.img+12
  • Valued Contributor
  • October 15, 2019

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.


Forum|alt.badge.img+2
  • New Contributor
  • June 17, 2021

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)


beeboo
Forum|alt.badge.img+7
  • Contributor
  • November 5, 2021