Need help with Applescript to wake Mac in several instances

I want to create an AppleScript that wakes the mac on multiple occasion during the day to use with KM. Can someone help?

Right now, with the default Power manager, you can only schedule 2 date and time ranges.

1 Like

You have two options: one is free and more complicated; the second is not free and very easy.

The free option is pmset which is already on your Mac, and can do these kinds of scheduling. But you have to use the Terminal to enter and edit the settings.

Power Manager is a great macOS app that almost no one knows about, because it has sold for $50. They just released a new version which has a subscription price as like $12/year (which is a total steal, IMO). It can do all of this and more. There are things I can do with Power Manager I could not do any other way, or without some truly terrible “hacks”.

Power Manger can not only turn your Mac on at certain times, it can run scripts, AppleScripts (which means that it can also run Keyboard Maestro macros), and more. You can do it based on a whole host of criteria. There’s a 30-day trial, I think it’s worth at least downloading and trying it out.

If you want to go the free route…well, I can’t blame you. But in that case you’re going to need to be very specific about what you’re looking to do, and when. And get familiar with the man page by going to Terminal and type man pmset or go to


What about the Home Brew option?

1 Like

I purchased a Power Manager subscription for 1 year. Now I can see if it will execute. Had to purchase because not all functionality was working during the trial.

I might need your help on how to use Keyboard Maestro to trigger PM.

Just curious; why not just keep it running, and only sleeping the screen? (My 2011 iMac ran for almost 8 years uninterrupted before I sold it)

1 Like

Why not use the cron option in KM?

Can that be triggered if the computer is sleeping?

I actually don’t know, but will check!

I bought Power Manager but I’m funding my computer is going to sleep a few seconds later. Can some please explain why? The Keyboard Maestro macro should have triggered caffeine.

I’d have to see your macro to try to help more, I think.

What I find strange is that with your power settings your computer would not actually sleep. I’m running just about the same settings and all my cron KM macros work perfectly.

Could be an issue with the KM install?

Here you go!

I checked this weekend, and with your energy settings my iMac runs all timed macros as normal. No issues whatsoever. Do you have another mac you can test this on?

OK, but what are your energy settings? Your Mac ran all timed macros with no issues, even when sleeping? How can that be? It’s been verified that Keyboard Maestro macros cannot execute when Mac is sleeping.

Please let me know what your energy settings are.

Is Caffeine working? I had that at one time and I thought the developer had stopped supporting it? I am not sure, I had another good one doing the same thing and same happened to that I think.

Caffeine is working, not sure if it is still in ongoing development.

Honestly, waking the Mac for the sake of Keyboard Maestro has been hit and miss.


I had a similar problem. I found that going into System Preferences > Energy Saver and adjusting the check boxes you find there helped, do both battery and power adapter tabs. I can’t now remember which ones I changed from default. There is one, that I don’t fully understand, about ‘power nap’, try that one. Try the option that stops you computer sleeping when the display is off too.
I think caffeine just works via the energy saver anyway or takes over its function in some way? I think you should adjust the settings on energy saver in preferences. You could avoid caffeine altogether by just setting the ‘turn off’ display slider in Energy Saver to ‘never’, which effectively is what Caffeine does? But you want your display off I guess? That is the point of this really for you? Just try the power nap and don’t sleep computer when display is off options.

Slightly OT, but I just happened to notice that in the latest update on MacUpdate about Caffeine it says:

“Caffeine is now maintained by IntelliScape Solutions

And on that page they add:

Originally developed by Tomas Franzén of Lighthead Software in 2006, Caffeine is a well known and loved utility for many Mac users, and its simplicity has allowed it to continue working perfectly long after active development ceased.

Unfortunately for many users, Caffeine began experiencing problems with the release of macOS Mojave, due to the enhanced privacy controls introduced which prevent Caffeine from functioning correctly.

We reached out to Tomas to inquire if we could continue development of Caffeine, as we believe it fits nicely with our vision of software that is simple, flexible and powerful.

Tomas has graciously provided the source code under an open source license, allowing us to continue developing Caffeine where he left off.

While I find myself happier with Amphetamine, it’s good to know Caffeine isn’t completely dead.


Thanks for that :smiley:. and the MacUpdate site which I didn’t know about, I like Caffeine. I think I used Amphetamine too sometime. I just put my native sleep settings to never turn off now though… Why do you think these are better options? Just curious really. I think Amphetamine had a schedule option? I suppose that is why…

@tjluoma Please help! I will try Amphetamine but I cannot get my Keyboard Maestro morning routine Macro to run properly.

Tried power manager, doesn’t do much. Also I can’t figure out if the default energy saver is interfering with something. I can post again in KM forum.