新版 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。非常感謝任何指導。
uj5u.com熱心網友回復:
在終端中試試這個:
sudo pmset -a lowpowermode 1
然后轉到Apple menu-> System Preferences->Battery看看它是否看起來不錯。
如果可行,我認為你會在 Applescript 中這樣做:
do shell script "pmset -a lowpowermode 1" with administrator privileges
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/457656.html
上一篇:使用命令輸出在LLDB中運行檔案
