How krishhgg/insomnia works
Insomnia is a macOS menu-bar app for timed keep-awake sessions. The user starts, extends, or ends a countdown; session management coordinates sleep prevention, lid-close actions, power rules, and cleanup. Settings configure those behaviors, while a journal and launchd backstop support recovery after app failure. The graph preserves documented capabilities even where implementation was not sampled; edges without direct source excerpts rely on README statements or SOURCE INDEX references, not a full inspection of those implementations.
Main entry points: SessionManager.swift Session manager · StatusItemController.swift Status controls · AppServices.swift Service coordinator · SettingsView.swift Settings window
Components 21
Menu-bar interface
- App lifecycle
Sources/Insomnia/InsomniaApp.swift - Status controls
Sources/Insomnia/UI/StatusItemController.swift - Countdown view
Sources/Insomnia/UI/StatusRootView.swift - Duration entry
Sources/Insomnia/UI/DurationInput.swift - Settings window
Sources/Insomnia/UI/SettingsView.swift
Session and recovery
- Session manager
Sources/Insomnia/Core/SessionManager.swift - Session timing
Sources/Insomnia/Core/SessionMath.swift - Service coordinator
Sources/Insomnia/Core/AppServices.swift - Recovery backstop
Sources/Insomnia/Core/LaunchdBackstop.swift
Mac integrations
- Lid actions
Sources/Insomnia/Core/LidActions.swift - Sleep prevention
Sources/Insomnia/Core/SleepGuard.swift - App freezing
Sources/Insomnia/System/Freezer.swift - Battery and heat rules
Sources/Insomnia/System/PowerMonitor.swift - Hotspot failover
Sources/Insomnia/System/NetworkFailover.swift - tmux nudges
Sources/Insomnia/System/TmuxNudge.swift
Settings and state
- User configuration
Sources/Insomnia/Model/Config.swift - Active session
Sources/Insomnia/Model/Session.swift - Session journal and state
Sources/Insomnia/Store/Store.swift - Persistent paths
Sources/Insomnia/Store/Paths.swift - Activity log
Sources/Insomnia/Core/Log.swift
Other components
- Mac user
Connections 24
- Mac user → Status controls: controls sessions
README.md - Mac user → Settings window: configures rules
README.md - App lifecycle → Status controls: creates interface
Sources/Insomnia/InsomniaApp.swift - Status controls → Countdown view: hosts view
Sources/Insomnia/UI/StatusItemController.swift - Status controls → Session manager: starts and ends
Sources/Insomnia/UI/StatusItemController.swift - Status controls → Duration entry: reads duration
Sources/Insomnia/UI/StatusItemController.swift - Countdown view → Session manager: shows session state
Sources/Insomnia/UI/StatusRootView.swift - Settings window → Session manager: updates settings
Sources/Insomnia/UI/SettingsView.swift - Session manager → Session timing: calculates deadlines
Sources/Insomnia/Core/SessionManager.swift - Session manager → Active session: tracks session
Sources/Insomnia/Core/SessionManager.swift - Session manager → Session journal and state: persists recovery state
Sources/Insomnia/Core/SessionManager.swift - Session manager → Service coordinator: starts integrations
Sources/Insomnia/Core/SessionManager.swift - Service coordinator → Lid actions: dispatches lid events
Sources/Insomnia/Core/AppServices.swift - Service coordinator → Battery and heat rules: runs power rules
Sources/Insomnia/Core/AppServices.swift - Lid actions → App freezing: freezes configured apps
Sources/Insomnia/Core/LidActions.swift - Session manager → Sleep prevention: prevents sleep
README.md - Session manager → Recovery backstop: arms recovery
Sources/Insomnia/Core/SessionManager.swift - Recovery backstop → Session journal and state: checks due recovery
README.md - Settings window → User configuration: edits preferences
Sources/Insomnia/UI/SettingsView.swift - Session manager → User configuration: uses preferences
Sources/Insomnia/Core/SessionManager.swift - Session journal and state → Persistent paths: resolves files
Sources/Insomnia/Store/Store.swift - Session manager → Activity log: records activity
Sources/Insomnia/Core/SessionManager.swift - Service coordinator → Hotspot failover: manages hotspot
Sources/Insomnia/Core/AppServices.swift - Hotspot failover → tmux nudges: triggers pane nudges
Sources/Insomnia/System/NetworkFailover.swift