PLIST files are formatted in XML and stand for property list files. They’re typically used by macOS applications for defining properties and configurations settings related with how the application itself will behave as a daemon/service.
See the following simple example for defining a service that will be greeting your everytime you turn on your mac:
1 |
|
The file above will be launched by running launchctl which is the command line interface for interacting with launchd. For those who are not familiar with launchd, it’s the service management framework used by macOS, similar in some ways to Service Control Manager on Windows or systemd on many Linux distributions.
Copy the snipped above and paste its content in a new file placed in ~/Library/LaunchAgents/com.example.agent.plist
First of we will proceed validating the plist file by running:
plutil ~/Library/LaunchAgents/com.example.agent.plist
output:
/Users/<username>/Library/LaunchAgents/com.example.agent.plist: OK
Now turn on your audio and proceed for activating our agent that will be greeting your everytime your mac is turned on:
launchctl load -w ~/Library/LaunchAgents/com.example.agent.plist
Here there is! you should have listened Siry greeting you, easy right?
In order to verify that the agent is running just type:
launchctl list com.example.agent
output:
1 | { |
As this is just a simple example about how services are managed in the macOS echosystem, anytime you want to turn off the agent just type:
launchctl unload -w ~/Library/LaunchAgents/com.example.agent.plist
Hope you find this brief introducction to how services/daemons are managed by macOS useful, if you want to know more visit:
- https://www.launchd.info/
- https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
Stay tuned!