如何使用AppleScript在Mac中设置低功率模式?
新版本的 macOS 引入了电池和电源适配器的低功耗模式。我正在构建一个应用程序,作为我想使用 applescript/shell 脚本设置或取消设置低功耗模式的一部分。
这是我到目前为止所写的内容,它非常有效,我可以获取低功耗模式的当前状态,无论它是打开还是关闭。
tell application "System Preferences"
do shell script "pmset -g | grep lowpowermode"
end tell
在上述步骤之后,我尝试“设置 lowpowermode 0”,但脚本抛出如下错误
tell application "System Preferences"
do shell script "set lowpowermode 0"
--> error number -10004
如何使用 applescript/shellscript 将低功耗模式设置为 0 或 1?
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
How do I set low power mode to 0 or 1 using applescript/shellscript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在终端中尝试此操作:
然后转到
Apple 菜单
->系统偏好设置
->电池
,看看它看起来是否良好。如果可行的话,我想你会在 Applescript 中这样做:
Try this in the Terminal:
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: