allowSleep
allowSleep reverses preventSleep, letting the system sleep normally again.
Signature
allowSleep(): Result<void, OsError>tyrus
import { OsError, allowSleep, preventSleep } from "tyrus:os";
match (preventSleep()) {
Ok() => print("Sleep prevention enabled"); // Sleep prevention enabled
Err(error) => printError(`${error.code}: ${error.message}`); // ERR_OS_SLEEP_INHIBIT_FAILED: platform sleep prevention is unavailable
}
match (allowSleep()) {
Ok() => print("Sleep prevention disabled"); // Sleep prevention disabled
Err(error) => printError(`${error.code}: ${error.message}`); // ERR_OS_SLEEP_ALLOW_FAILED: platform sleep prevention could not be released
}Idempotent: calling this with nothing inhibited is a no-op success, matching preventSleep's own idempotence. Returns Err(OsError) with code ERR_OS_SLEEP_ALLOW_FAILED if the platform API cannot restore normal sleep behavior.
OsError Fields
| Field | Type | Meaning |
|---|---|---|
code | string | A stable, machine-readable identifier. |
message | string | A human-readable description of what went wrong. |
