Programmatically put a Mac into sleep

后端 未结 6 1003
清歌不尽
清歌不尽 2021-02-03 13:21

I can\'t find any instructions how to put a Mac programmatically into sleep mode (in Objective-C). I\'m sure it should be only one line, but could you give me a hint?

6条回答
  •  孤城傲影
    2021-02-03 14:18

    I found that running pmset sleepnow worked during a screensaver, while the first two answers did not.

提交回复
热议问题