'Turn On macOS Screen Remotely

Is there a way to turn on the monitor remotely on macOS? I'm trying to write an app that will do this.

I've tried a couple of things but can't seem to find a way of triggering the screen to turn on after it has been turned off for power saving.

I've got a macOS app that advertises itself on the network via Bonjour. I can communicate to it via sockets, even when the computer is sleeping. However, I'm not sure what I can do from this macOS app that would trigger the screen to come on. I've tried sending a WoL packet and I've tried using Caffiene.

The macOS app doesn't need to pass Apple Review so I'm fine with using private APIs if necessary.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source