feat(macos): turn the light off on system sleep / shutdown#17
Merged
Conversation
Adds two opt-in toggles under Settings → Behaviour that switch the selected light off just before the Mac sleeps or shuts down, so it is not left lit in an empty room. Sleep is handled by an NSWorkspace.willSleepNotification observer (synchronous, on the main thread). Shutdown/logout/restart reuses the existing isSystemInitiatedQuit check in applicationShouldTerminate, with sudden termination disabled so that path is guaranteed to run. Both fire a synchronous WizClient.sendNow power-off so the command leaves the machine before the network drops, unlike the usual debounced async path. The prefs persist in UserDefaults (a macOS-only behaviour, kept out of the shared cross-tool settings.json, mirroring UpdateChecker.autoCheckEnabled) and default off.
Bump root, wiz-light-core, wiz-light-cli, and the macOS app (CFBundleShortVersionString 0.6.0 / build 18) in lockstep, alongside the sleep/shutdown auto-off feature in this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two opt-in Settings → Behaviour toggles turn the selected light off just before the Mac sleeps or shuts down — so it is not left lit in an empty room.
How
NSWorkspace.willSleepNotificationobserver, selector-based so it runs synchronously on the main thread during the sleep transition — the off datagrams egress while Wi-Fi is still up.isSystemInitiatedQuit()check inapplicationShouldTerminate;disableSuddenTermination()guarantees that path runs instead of a SIGKILL.WizClient.sendNowpower-off (3×, ≈240 ms) rather than the usual debounced/async send, which would never leave the machine before the NIC sleeps.UserDefaults(macOS-only behaviour — kept out of the shared cross-toolsettings.json, mirroringUpdateChecker.autoCheckEnabled). Both default off.Test plan
swift build+swift test(15 WizKit tests) green.pmset sleepnow→ bulb turns off; disable → stays on. Enable shutdown → Apple menu → Restart → bulb turns off; quitting the app from the menu bar leaves the light untouched.