Check if display is at sleep or receive sleep notifications

前端 未结 3 1593
时光说笑
时光说笑 2021-02-06 19:16

I have an application utility which becomes useless when there\'s no user. So, in order to save resources, I\'d like it to know when/whether display is at sleep.

There\'

3条回答
  •  渐次进展
    2021-02-06 20:21

    This is response to a question asked a while ago - but I thought it would be useful to add my answer.

    NSWorkspace has a couple of notifications for when displays wake and sleep: NSWorkspaceScreensDidSleepNotification and NSWorkspaceScreensDidWakeNotification

提交回复
热议问题