Repository navigation
Description
Before opening the issue, have you...?
- Searched for existing issues
Is your feature request related to a problem? Please describe
MonitorControl currently launches at login unconditionally when "Start at login" is enabled. For users who only use the app with external displays (e.g., MacBook users who work mostly on the go), this means the app runs even when it's not needed, consuming resources and showing a menu bar icon that has no function without external monitors.
Describe the solution you'd like
Add conditional logic so that when the app launches at login, it checks whether external displays are connected. If no external displays are detected, the app should terminate early before showing the menu bar icon or running the full configuration.
Proposed approach:
- Modify
MonitorControlHelper/main.swiftto pass a flag (e.g.,--launched-at-login) when launching the main app - In
AppDelegate.applicationDidFinishLaunching, check for this flag and the absence of external displays beforesetMenu()andconfigure() - If both conditions are true, call
NSApp.terminate(nil)and return early - Use
CGDisplayIsBuiltin()to detect external displays (this API is already used throughout the codebase)
Timing consideration: Display enumeration may not be complete at login time. Two mitigation strategies:
- Add a short delay (1-2 seconds) before checking
- Better: register a one-shot
CGDisplayRegisterReconfigurationCallbackto re-check when a display is connected later
Describe alternatives you've considered
-
Conditional launch at login registration: Not feasible with
SMLoginItemSetEnabled— it's a boolean registration with launchd that has no conditional triggers. -
Migrate to SMAppService (macOS 13+): While
SMAppServiceoffers more control, it still doesn't support conditional triggers based on display state. This would be a larger architectural change without solving the core problem. -
User manually toggles "Start at login": Works but defeats the purpose of automation. Users with hybrid setups (sometimes external, sometimes not) would need to toggle the setting frequently.
Anything else?
Key files involved:
MonitorControlHelper/main.swift(lines 1-26) — helper that launches main app at loginAppDelegate.swift(lines 53-69) —applicationDidFinishLaunchingstartup flowAppDelegate.swift(line 65) — existingCGDisplayRegisterReconfigurationCallbackusageDisplayManager.swift(lines 163-190, 290-292) — existing display enumeration andCGDisplayIsBuiltinusage
This is a low-risk change that touches 2-3 files, uses existing infrastructure, and doesn't require architectural changes. I'd be happy to implement this if the maintainers think it's a good fit for the project.
Activity