feat(macos): restore the light on wake / startup, add open-at-login#20
Merged
Conversation
Replace the two "turn the light off on sleep / shutdown" toggles with a per-event choice — Do nothing / Turn off / Turn off, then restore — shown as pop-up menus in Settings. "Restore" turns the light back on when the Mac wakes (sleep) or next launches (shutdown); a bare power-on lets the bulb relight to its own remembered colour and brightness. - PowerEventAction enum, persisted in UserDefaults; pre-5.x Bool prefs are migrated forward (legacy on -> Turn off). Installs with no stored choice default to "turn off, then restore", and the app opens at login. - Restore is gated: only when the light was connected and on at the time, only within a grace window, and boot-restore only at low system uptime so opening the app by hand long after a normal boot won't toggle the light. An explicit power toggle or disconnect cancels a pending restore. - Add an "Open at login" toggle backed by SMAppService (new LoginItem.swift), needed so restore-on-startup can run after a reboot; defaults on and is auto-enabled when a shutdown restore is chosen. - Observe NSWorkspace.didWakeNotification to drive the wake restore.
Bump the root, core, and cli package versions and the app's CFBundleShortVersionString to 5.1.0 in lockstep (CFBundleVersion 18 -> 19), so the release workflow publishes on merge to main. Ships the sleep/shutdown turn-off-then-restore options and the open-at-login toggle.
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.
What
Replace the sleep/shutdown "turn the light off" toggles with a per-event choice — Do nothing / Turn off / Turn off, then restore — shown as pop-up menus in Settings. "Restore" brings the light back on when the Mac wakes (sleep) or next launches (shutdown), letting the bulb relight to its own remembered colour/brightness. Adds an Open at login toggle (SMAppService) so restore-on-startup can run after a reboot.
Behaviour / defaults
Files
AppState.swift—PowerEventAction, migration, restore plumbing,openAtLoginLoginItem.swift(new) —SMAppService.mainAppwrapperAppDelegate.swift—didWakeNotificationobserverViews/SettingsView.swift— two pickers + login toggle + hintTest plan
swift buildclean;swift test15/15.pmset sleepnow).SMAppServiceto register (ad-hoc signing may not take effect).