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.