Autostart on Mac OS X - nosmokingbandit/watcher GitHub Wiki
Create a file called net.nosmokingbandit.watcher.plist in your ~/Library/LaunchAgents directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>watcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>watcher.py</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/watcher</string>
</dict>
</plist>
Change line 21 to the absolute path of your watcher folder Make sure your watcher folder matches your user permissions (otherwise the launchd service might fail to start):
sudo chown -R $(whoami) /opt/watcher
(change this path to the path of your watcher folder from above)
In Terminal:
To enable the daemon: launchctl load ~/Library/LaunchAgents/net.nosmokingbandit.watcher.plist
To disable the daemon: launchctl unload ~/Library/LaunchAgents/net.nosmokingbandit.watcher.plist
Enjoy! This will automatically start watcher when you login
Create a file called net.nosmokingbandit.watcher.plist in your /Library/LaunchAgents directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>watcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>watcher.py</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/watcher</string>
</dict>
</plist>
Change line 21 to the absolute path of your watcher folder In Terminal:
To enable the daemon: sudo launchctl load /Library/LaunchAgents/net.nosmokingbandit.watcher.plist
To disable the daemon: sudo launchctl unload /Library/LaunchAgents/net.nosmokingbandit.watcher.plist
Enjoy! This will automatically start watcher when your machine boots