How to wake the display automatically?

Hello, I've got a macro that needs to run a Filemaker script every night, after verifying that Filemaker is running and the website in question is logged in. The macro works flawlessly every time I test it manually, with the display on, but when it's running by itself with the display off (but the computer fully awake), it seems to stop partway.

So how can I reliably wake up the display before running my macro automatically? I tried some mouse movements and clicks but it doesn't seem 100% reliable.

Thanks in advance!

There is a macOS command called "pmset" which lets you use the command line to access a variety of power-related situations. You can run this command using the Execute Shell Script action.

As I'm reading the documentation, I see that you may have to use that command to schedule a time of day for the monitor to waken. I haven't used pmset in a while, so I'm not very adept with it.

1 Like

pmset will require sudo and a password (or editing sudoers so it can be used passwordless) and, as @Airy says, needs to be scheduled. Not a problem in itself except I think you can only have one event scheduled (although you can get round that by re-writing the schedule with a script).

How about caffeinate instead? Something like

caffeinate -u -t 60

...run in an Execute Shell Script action should wake your display and keep it awake for (at least) the next 60 seconds -- change the time to suit the run-time of your macro if the display is sleeping half-way through and breaking things.

4 Likes

This seems to work perfectly, thanks very much!

This works too in shortcuts. :ok_hand: