You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Musubi/Packages/MusubiKit/Sources/VideoOutput/SleepBlocker.swift

21 lines
576 B

import IOKit.pwr_mgt
/// Keeps the display (and therefore the system) awake while held.
public final class SleepBlocker {
private var assertion: IOPMAssertionID = 0
public init?(reason: String) {
let result = IOPMAssertionCreateWithName(
kIOPMAssertionTypePreventUserIdleDisplaySleep as CFString,
IOPMAssertionLevel(kIOPMAssertionLevelOn),
reason as CFString,
&assertion
)
guard result == kIOReturnSuccess else { return nil }
}
deinit {
IOPMAssertionRelease(assertion)
}
}

Powered by TurnKey Linux.