https://github.com/andrewpetrochenkov/mac-agents.py
:apple: LaunchAgents + python
https://github.com/andrewpetrochenkov/mac-agents.py
cli macos python
Last synced: 8 days ago
JSON representation
:apple: LaunchAgents + python
- Host: GitHub
- URL: https://github.com/andrewpetrochenkov/mac-agents.py
- Owner: andrewpetrochenkov
- License: unlicense
- Created: 2018-12-08T02:15:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-03T21:04:42.000Z (about 5 years ago)
- Last Synced: 2025-02-26T09:41:59.612Z (11 months ago)
- Topics: cli, macos, python
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://pypi.org/project/mac-agents/)
[](https://unlicense.org/)
[](https://github.com/andrewp-as-is/mac-agents.py/actions)
### Installation
```bash
$ [sudo] pip install mac-agents
```
#### Examples
`~/Library/LaunchAgents/file.py`
```python
import mac_agents
class Agent(mac_agents.Agent):
StartInterval = 5 # capital letter
def run(self):
pass
if __name__ == "__main__":
Agent().run()
```
```bash
$ find ~/Library/LaunchAgents -name "*.py" | xargs python -m mac_agents.create "$@"
$ find ~/Library/LaunchAgents -name "*.plist" | xargs launchctl load # or launchctl unload
$ launchctl list | grep .py$ | awk '{print $3}' | xargs -I '{}' launchctl remove {}
$ find ~/Library/LaunchAgents -name "*.py.plist" -exec rm {} +
```
#### Links
+ [launchd.plist](https://www.real-world-systems.com/docs/launchd.plist.5.html)