Add System Launch event with boot-time detection#9
Draft
Conversation
Co-authored-by: liopoos <12404909+liopoos@users.noreply.github.com>
Co-authored-by: liopoos <12404909+liopoos@users.noreply.github.com>
…ng comments Co-authored-by: liopoos <12404909+liopoos@users.noreply.github.com>
Co-authored-by: liopoos <12404909+liopoos@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add new system launch event for notifications
Add System Launch event with boot-time detection
Feb 9, 2026
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.
Adds a new event type that fires once per system boot rather than per app launch. Uses
sysctl(KERN_BOOTTIME)to detect actual boot time and persists last-notified boot timestamp in UserDefaults.Changes
systemLaunchcase with tag 140nilon sysctl failure to prevent false positivesapplicationDidFinishLaunching, triggers event if enabledSYSTEM_LAUNCHandEVENT_SYSTEM_LAUNCHkeys to all locale filesImplementation
Menu automatically includes the new event via
Event.allCasesiteration.Original prompt
Problem Statement
Add a new "System Launch Event" that sends a notification only once after system startup (boot), not on subsequent app launches. This is different from an "App Launch Event" which would fire every time the app is opened.
Requirements
1. Add New Event Type to
EventEnumIn
HemuLock/Enums/Event.swift:systemLaunch = "SYSTEM_LAUNCH"to the enum140(following the pattern: 110-111 for screen, 120-121 for system sleep, 130-131 for lock)2. Implement System Boot Detection Logic
Create a new manager file
HemuLock/Managers/SystemBootManager.swift:sysctlto get system uptimefunc isNewSystemBoot() -> Boolfunc markBootNotified()3. Trigger System Launch Event in AppDelegate
In
HemuLock/AppDelegate.swift, in theapplicationDidFinishLaunchingmethod:EventObserver(line 373)SystemBootManagerobserver?.handleEvent()with a mock notification forEvent.systemLaunch4. Update EventObserver
In
HemuLock/EventObserver.swift:handleEventmethod should work with the new event type5. Add Localization Strings
Add to all localization files:
HemuLock/en.lproj/Localizable.strings:HemuLock/zh-Hans.lproj/Localizable.strings:HemuLock/Base.lproj/Localizable.strings:6. Update Menu Structure
In
HemuLock/Controllers/MenuController.swift:Event.allCases(line 48)7. Update AppConfig Default Events
In
HemuLock/Models/AppConfig.swift:[Event.systemLock.tag, Event.systemUnLock.tag]Technical Implementation Details
System Boot Detection Logic
Use
sysctlto get system uptime:Store in UserDefaults:
"last_notified_boot_time"Integration Point
In
AppDelegate.applicationDidFinishLaunching:Files to Modify
HemuLock/Enums/Event.swift- Add new event caseHemuLock/Managers/SystemBootManager.swift- Create new fileHemuLock/AppDelegate.swift- Add system boot check logicHemuLock/en.lproj/Localizable.strings- Add localizationHemuLock/zh-Hans.lproj/Localizable.strings- Add localizationHemuLock/Base.lproj/Localizable.strings- Add localizationTesting
After implementation, test:
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.