Prevent macOS from sleeping during processing

I tried the Topaz Video demo and left it to process a video while I went out for lunch. After ~5 minutes my computer went to sleep rather than Topaz Video keeping the computer awake until the processing finished.

You should be able to use IOKit on macOS to prevent the system from going to sleep like this:

#include <IOKit/pwr_mgt/IOPMLib.h>

IOPMAssertionID assertionID = kIOPMNullAssertionID;

IOReturn result = IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleSystemSleep, kIOPMAssertionLevelOn, CFSTR("Topaz Video is performing a long-running operation"), &assertionID);

if (result != kIOReturnSuccess) {
  // Handle failure
}

// ... keep the system awake while ffmpeg processes file...

if (assertionID != kIOPMNullAssertionID) {
  IOPMAssertionRelease(assertionID);
}

moved this to the ideas section for users to vote on it for consideration.

Good idea, I have to remember to use caffeinate for now…

I would love this feature, since I’m also having to utilize Amphetamine to keep my Mac awake when processing videos on my M1 Max MacBook Pro and M4 Mac mini.

I just upgraded to Tahoe and Video 1.7. I have been struggling to figure out how to keep my mac from sleeping during Starlight renders. The screen saver, energy controls, lock screen, etc. are now all separate menus with confusing names and explanations. Every time I think I have solved the issue the computer goes to sleep anyway. Starlight is already slow, having my mac go to sleep halfway though a render is exasperating.

I have caffeinate running with no issues… Always powered… Also these settings:

  • Battery / Prevent automatic sleeping on power adapter when the display is off should be disabled
  • Wallpaper / Start Screen Saver set to Never
  • Lock screen has defaults settings

Hope this helps

I’m going to try using caffeinate tonight before I go to bed. I have set my system settings now to what you have suggested, at least as far as they apply - I have a M4 Mac Mini Base. The system settings are of course a bit different since it doesn’t have a built-in screen or battery.

I don’t use caffeinate on the mac mini, only on the MacBook. I am on macOS 27 on the MacMini, so the menu is under Energy:

  • Prevent automatic sleeping on power adapter when the display is off is enabled

I think this must be the most important settings.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.