如何在OS X上通过终端(最好是使用Python脚本)禁用强制睡眠(由用户引起的睡眠 - 通常是通过关闭盖子/在Apple菜单下按Sleep)?我希望能够运行以下或类似的......
import os
cmd = """ *?*Sleep Disable Command*?* """
def fullVolume():
os.system(cmd)
while True:
fullVolume()
......完成上述任务。
我已经做了相当多的研究,而且我找不到多少,请注意:https://developer.apple.com/library/mac/qa/qa1340/_index.html
这个: https://code.google.com/p/macosx-nosleep-extension/ https://github.com/integralpro/nosleep/releases
我相信可能有一些方法可以将NoSleep扩展中的代码合并到这个脚本中,但我不确定如何这样做。非常感谢帮助! =)
答案 0 :(得分:0)
osascript -e 'tell application "System Events" to sleep'
〜
str1='tell application "System Events" to sleep'
os.system("osascript -e '"+ str1+ "'")