Repository navigation
DisplayToggle 1.1
Fixes a black-screen recovery failure reported on machines other than the one this was developed on. If you use 1.0, please update.
Unplugging the external display could leave you on a black screen
The emergency recovery guessed display IDs by iterating 0..<40. CGDirectDisplayID is opaque — on the development machine it happens to be 1, 2, 3, so the range worked in every local test. Many Macs report values like 69733248, where the batch never touches the built-in display and recovery silently does nothing.
Every display ID the app has seen is now persisted while enumeration still works, and recovery uses that set instead of a guessed range.
Manually turning the display back on reported CGError 1001
CGSCompleteDisplayConfiguration routinely returns kCGErrorIllegalArgument (1001) while the display does come back on. That return code was treated as fatal, which produced a bogus error dialog and aborted a recovery that may well have succeeded. The real display state is polled now; only a genuinely unchanged state counts as a failure.
Clicking "turn on" while already stranded also did nothing at all, because it went through the normal path which cannot see the built-in display in that state. The menu now offers Restore built-in display and routes to the emergency recovery.
Also
- CLI: added the missing virtual-display detection, and declared
argtypesforCGDisplayVendorNumber/CGDisplayModelNumber— large display IDs would otherwise have been passed as signed values - selftest: checks that don't require toggling a display now run on single-screen machines too
Install: download the .dmg, drag to Applications. Ad-hoc signed and not notarized, so right-click → Open on first launch, or:
xattr -dr com.apple.quarantine /Applications/DisplayToggle.app
Requires macOS 13+.