Repository navigation
DisplayToggle 1.6
1.5's fix never actually ran. This makes it work. If you installed 1.5, update.
What went wrong
The log from an affected machine showed the entire recovery finishing in 0–300ms — while the sleep/wake step alone takes six seconds. The chain was returning early, convinced it had already succeeded.
Success was checked with CGDisplayIsActive(id) != 0. But these boolean_t functions return 0xFFFFFFFF for an invalid ID, not 0 or 1:
CGDisplayIsActive(99999) = 4294967295
Once the display IDs go invalid — exactly the situation recovery exists for — that error code reads as true. The first stage declared success and the step that actually works was never reached.
It also explains why the standalone diagnostic script succeeded where the app failed: the script decided from the enumeration, the app asked this function.
Fixed
- Display state is now decided from the enumeration, never by trusting these functions directly
- Where their return value is used, it tests
== 1instead of!= 0 - ID-based stages are skipped once the built-in display has vanished from the enumeration — they cannot succeed then, and only cost black-screen time
- Recovery returns immediately when the built-in display is present but asleep: that is a closed lid, not a failure
The self-test asserts an ID that doesn't exist is never treated as lit, and prints the raw return value so the trap stays visible.
Ad-hoc signed and not notarized: right-click → Open on first launch, or xattr -dr com.apple.quarantine /Applications/DisplayToggle.app. Requires macOS 13+.