新版本的macOS为电池和电源适配器引入了低功耗模式。我正在构建一个应用程序,作为我的一部分,我想设置或取消设置低功耗模式使用applescript/shell脚本。
这是我写到目前为止,这是伟大的工作,我可以得到当前的低功耗模式的状态,无论是打开还是关闭。
tell application "System Preferences"
do shell script "pmset -g | grep lowpowermode"
end tell在上述步骤之后,我尝试“设置低电源模式0”,但是脚本抛出了一个类似于下面的错误
tell application "System Preferences"
do shell script "set lowpowermode 0"
--> error number -10004如何使用applescript/ set脚本将低功耗模式设置为0或1?
发布于 2022-04-06 13:53:01
在终点站试试这个:
sudo pmset -a lowpowermode 1然后去Apple menu -> System Preferences -> Battery,看看它是否好看。
如果这样做有效,我认为您应该在Applescript中这样做:
do shell script "pmset -a lowpowermode 1" with administrator privilegeshttps://stackoverflow.com/questions/71766823
复制相似问题