Expand description
macOS: start at login through SMAppService, so the entry shows in System Settings -> General -> Login Items &
Extensions where people look for it, and respects the approval they give there
(docs/specs/SPEC_START_WITH_OS_2026_09_25.md §3.7, phase 4).
§What is registered, and why not SMAppService.mainApp
A bundle that ships Contents/Library/LaunchAgents/<label>.plist registers that agent
(SMAppService.agent(plistName:)). The plist’s job is the launcher itself with --login-start: a shim that, at
login, opens the app through LaunchServices (open <app> --args --background) unless it already runs, then exits.
mainAppcannot carry--background, which is what makes a login start a tray start with no window.- An agent whose job is AgentMux dies when the entry is switched off: unregistering boots the job out and launchd stops its process (checked on macOS 26.5, 2026-11-20). With the shim, the running app is a LaunchServices child, not the job, so Settings can switch the entry off from inside the app that login started.
- A process started by
launchdrather than LaunchServices is refused byUNUserNotificationCenter(“notifications are not allowed”, with no prompt; checked on macOS 26.5). Going throughopenkeeps the login-started app able to notify. BundleProgrammust be a signed Mach-O inside the bundle: a shell script fails launchd’s launch constraints.
The plist ships only in a bundle whose identifier is stable across versions (scripts/package-macos.sh); a bundle
without it keeps writing the LaunchAgent plist of autostart/mod.rs, so nothing changes for dev, test or
per-version builds. Registering an entry replaces that LaunchAgent plist (no double start, no orphan).
Modules§
- platform 🔒
Enums§
- Registration
SMAppService.Status.
Constants§
- AGENT_
PLIST_ DIR - The folder inside an app bundle that holds a registrable agent plist.
- LOGIN_
START_ FLAG - What the launcher is asked to do by the login job: start AgentMux through LaunchServices if it is not running.
- OPEN_
LOGIN_ ITEMS_ FLAG --open-login-items: open System Settings at Login Items (the page where the person approves AgentMux).
Functions§
- agent_
plist_ in - The file name of the agent plist a bundle ships, when it ships exactly one. More than one is a packaging mistake (which would the system start?), so it counts as none.
- available
- Whether start at login goes through
SMAppServicein this launcher. - bundle
- The app bundle and agent plist name this launcher registers: set when this launcher runs from an app bundle that
ships an agent plist and the system has
SMAppService(macOS 13).Noneeverywhere else. - bundled_
agent_ 🔒plist - The agent plist the bundle that holds
appships: its file name, if it ships exactly one. - login_
start - What the login job does: nothing when this app already runs (a registration made while it is open, or a second login item), otherwise open it through LaunchServices in background mode and leave. Returns the exit code.
- open_
settings - Open System Settings at Login Items, where the person allows AgentMux (status
RequiresApproval). - register
- Register the agent. Re-registering one that is registered is not an error.
- registration
- The registration as the system has it.
Nonewhenavailableis false or the system does not answer. - registration_
from_ raw - The raw
SMAppService.Status(notRegistered0,enabled1,requiresApproval2,notFound3). - unregister
- Remove the registration. Succeeds when there is none.