Launch processes automatically
register a process for automatic launch
Applications (or simple processes) may request the OS to automatically launch them at boot-up or at user-login.
Boot-up items start before login, for critical services that should run as soon as possible and regardless of the user.
Login items start on user login, and may launch applications automatically.
traditional registration process
We craft a plist file that identifies a process and provides some settings such as the launch arguments. We then place it in a hardcoded directory.
We place it in /Library/LaunchDaemons if it has to start on boot-up. We place it in either /Library/LaunchAgents or ~/Library/LaunchAgents if it has to start on user login.
macOS manages a distinct database to keep track of which item has been disabled from the OS login-items settings.
open /Library/LaunchDaemons
open /Library/LaunchAgents
open ~/Library/LaunchAgents
sfltool dumpbtm
launchctl print-disabled user/$(id -u)
modern registration process
applications are now encouraged to store the plist files inside their bundles and register them through a macOS API. This ends the pattern of having plist files outside of their bundles.
MyApp.app/
└── Contents/
├── Info.plist
├── MacOS/
│ └── MyApp (The main executable)
└── Library/
└── LaunchAgents/
└── com.myapp.helper.plist