Apple Script to change System Preferences

Hey guys, can you please help me with a script that would toggle this setting in the background without opening preferences? My plan is to run it on battery trigger.

Thank you!

defaults -currentHost write Battery -int 8

defaults -currentHost write Battery -int 2

Can be called from Apple Script like this:

do shell script "defaults -currentHost write Battery -int  8"
1 Like

Ah, I outlined the wrong toggle! How can I do the same but for battery percentage? :sweat_smile:

Thank you so much!

For that this should do the trick:


defaults -currentHost write BatteryShowPercentage -bool true


defaults -currentHost write BatteryShowPercentage -bool false

Might be a nice default action for BTT to have to quickly show/hide the battery percentage.

With the new System Settings, is there a new way to change the Displays: Rotation: 90° or Standard?

I was using GUI scripting, but it's not the best.

For instance, is there a way to write to instead of ?

I don't think there is. But there is a free app that can do this (and much more)
Releases · waydabber/BetterDisplay (

This is great advice, thank you!
This is exactly what I needed.

oh but I just noticed it's not free (really great app though)

This worked perfectly, thank you! Indeed, I'd love to see this action in BTT. Would also be cool to have "Battery charging" trigger

It's pretty weird, I have set up two automations - to turn battery percent on when it's below 11% and turn it off when it's above 10%. First automation works fine, but second one doesn't do anything and percentage stays on when it's above 10.

It looks like they have some Pro settings under a trial period.

But the basic functionality I need looks like it's included past the trial.

It was a good suggestion, thanks again.