How jclee777/display-switch-lab works
DisplaySwitchLab is a macOS menu-bar utility for choosing which built-in and external displays are enabled. The main workflow starts in the menu or global-shortcut panel, selects a mode, and delegates switching and recovery to the display model. The README also documents customizable shortcuts, login launch, localization, hot-plug recovery, and restoration on quit. Sampled code supports the model-to-switcher and persistence relationships; some implementation details are omitted, so uncertain wiring is not shown.
Main entry points: DisplaySwitchLabApp.swift Menu bar · DisplaySwitchModel.swift Display model · QuickSwitchPanel.swift Quick switch panel · Localization.swift Localization
Components 19
App interface
- Application lifecycle
Sources/display-switch-lab/DisplaySwitchLabApp.swift - Menu bar
Sources/display-switch-lab/DisplaySwitchLabApp.swift - Quick switch panel
Sources/display-switch-lab/QuickSwitchPanel.swift - Global shortcut
Sources/display-switch-lab/QuickSwitchPanel.swift - Shortcut and about UI
Sources/display-switch-lab/AppPreferences.swift
Switch control
- Display model
Sources/display-switch-lab/DisplaySwitchModel.swift - Session recovery state
Sources/display-switch-lab/DisplaySwitchModel.swift - External display watchdog
Sources/display-switch-lab/DisplaySwitchModel.swift
Display platform
- Display switcher
Sources/display-switch-lab/DisplaySwitchModel.swift - Display inventory
Sources/display-switch-lab/DisplaySwitchModel.swift - Display enable API
Sources/display-switch-lab/DisplaySwitchModel.swift - Known display store
Sources/display-switch-lab/DisplaySwitchModel.swift
Preferences
- Shortcut preferences
Sources/display-switch-lab/AppPreferences.swift - Login launch setting
Sources/display-switch-lab/LaunchAtLogin.swift - Localization
Sources/display-switch-lab/Localization.swift - English and Chinese strings
Sources/display-switch-lab/Resources
Other components
- User
- macOS display services
- macOS login service
Connections 28
- User → Menu bar: chooses mode
- User → Global shortcut: presses shortcut
- Menu bar → Display model: applies mode
- Menu bar → Quick switch panel: opens panel
- Menu bar → Shortcut and about UI: opens settings UI
- Menu bar → Login launch setting: toggles launch
- Global shortcut → Shortcut preferences: loads shortcut
- Global shortcut → Quick switch panel: opens or cycles
- Quick switch panel → Display model: commits mode
- Shortcut and about UI → Shortcut preferences: saves shortcut
- Application lifecycle → Display model: starts and restores
- Application lifecycle → Quick switch panel: configures and stops
- Display model → Session recovery state: tracks display state
- Display model → Display switcher: queries and switches
- Display model → External display watchdog: arms recovery
- Display switcher → Display inventory: fetches displays
- Display switcher → Known display store: records and restores IDs
- Display switcher → Display enable API: enables displays
- Display inventory → macOS display services: reads display state
- Display enable API → macOS display services: configures displays
- Known display store → macOS display services: stores display IDs
- External display watchdog → Display switcher: checks and restores
- Shortcut preferences → User: persists shortcut
- Login launch setting → macOS login service: registers service
- Menu bar → Localization: gets interface text
- Quick switch panel → Localization: gets interface text
- Shortcut and about UI → Localization: gets interface text
- Localization → English and Chinese strings: loads translations