Skip to content

Option to skip launch at login when no external displays are connected #1880

Description

@looreenz

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:

  1. Modify MonitorControlHelper/main.swift to pass a flag (e.g., --launched-at-login) when launching the main app
  2. In AppDelegate.applicationDidFinishLaunching, check for this flag and the absence of external displays before setMenu() and configure()
  3. If both conditions are true, call NSApp.terminate(nil) and return early
  4. 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 CGDisplayRegisterReconfigurationCallback to re-check when a display is connected later

Describe alternatives you've considered

  1. Conditional launch at login registration: Not feasible with SMLoginItemSetEnabled — it's a boolean registration with launchd that has no conditional triggers.

  2. Migrate to SMAppService (macOS 13+): While SMAppService offers 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.

  3. 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 login
  • AppDelegate.swift (lines 53-69) — applicationDidFinishLaunching startup flow
  • AppDelegate.swift (line 65) — existing CGDisplayRegisterReconfigurationCallback usage
  • DisplayManager.swift (lines 163-190, 290-292) — existing display enumeration and CGDisplayIsBuiltin usage

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssue is a new feature proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions