Home > Blockchain >  How to set low power mode in mac using applescript?
How to set low power mode in mac using applescript?

Time:04-07

The new version of macOS introduced low power mode for battery and power adaptor. I am building an app, as a part of I would like to set or unset low power mode using applescript/shell script.

This is what I've written so far which works great where I can get the current status of low power mode whether if it is on or off.

tell application "System Preferences"
    do shell script "pmset -g | grep lowpowermode"
end tell

After the above step I tried to "set lowpowermode 0" but the script is throwing an error like below

tell application "System Preferences"
    do shell script "set lowpowermode 0"
        --> error number -10004

My goal is to set low power mode to 0 or 1 using applescript/shellscript. Any guidance is highly appreciated.

CodePudding user response:

Try this in the Terminal:

sudo pmset -a lowpowermode 1

Then go to Apple menu -> System Preferences -> Battery and see if it looks good.


If that works, I think you'd do it in Applescript something like this:

do shell script "pmset -a lowpowermode 1" with administrator privileges
  • Related