Skip to content

Fall back to IOPMrootDomain when pmset omits SleepDisabled - #2

Open
Matte1404 wants to merge 1 commit into
TurboKach:mainfrom
Matte1404:fix/macos27-sleepdisabled-fallback
Open

Matte1404 wants to merge 1 commit into
TurboKach:mainfrom
Matte1404:fix/macos27-sleepdisabled-fallback

Conversation

@Matte1404

Copy link
Copy Markdown

Fixes #1

On macOS 27, pmset -g does not print SleepDisabled until disablesleep has been written explicitly. PMSet.read() threw in that state, so keep-awake could not be enabled.

read() now falls back to the IOPMrootDomain SleepDisabled property when the pmset output has no usable line. A read that fails both ways still throws, so a failed read never counts as sleep enabled.

Tests: swift test passes (78 tests), including three new SystemAdaptersTests covering the fallback. Verified on macOS 27.0.1: pmset -g omits the line, and the IORegistry value matches ioreg.

On macOS 27, `pmset -g` does not print SleepDisabled until
disablesleep has been written explicitly. PMSet.read() threw in
that state, so keep-awake could not be enabled (issue TurboKach#1).

read() now uses the IOPMrootDomain SleepDisabled property when the
pmset output has no usable line. A read that fails both ways still
throws, so a failed read never counts as sleep enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BugFix LidAwake not working in macOS 27

1 participant