Reputation: 29
I'm developing a Swift application for macOS and I would like to retrieve the list of windows that are preventing Sleep. Like the column in Activity Monitor->Energy. Is there a way to retrieve this attribute in Swift? Thank you
Upvotes: 1
Views: 143
Reputation: 75
Yes, you can do this with:
var assertions: Unmanaged<CFDictionary>?
if IOPMCopyAssertionsByProcess(&assertions) != kIOReturnSuccess {
fatalError("Error with assertions")
}
and in there you can find various assertions, and also Prevent screen dim and system stop
Upvotes: 1