How to get a service working upon launch
You can make this work with launchd. This requires two steps: First creating a script that invokes your service(s), and second creating a LaunchAgent plist file that will call the script at launch.
First step: Creating a script that invokes your service(s)
-
Write a text file with the following content, where
~/Library/Services/myservice.workflow
points to the service you want to start (if you want to start more than one service, repeat the second line pointing to the different services):#!/bin/bash automator ~/Library/Services/myservice.workflow
Save the file, e.g. as
~/Library/LaunchAgents/me.myname.launchmyservice.sh
-
Make it executable by issuing the following command in the Terminal:
chmod u+x ~/Library/LaunchAgents/me.myname.launchmyservice.sh
Second step: Creating a LaunchAgent plist that calls the script
-
Write a text file with the following content. You need to adapt the string
/Users/myusername/Library/LaunchAgents/me.myname.launchmyservice.sh
so it points to the script created in the first step. You cannot use a relative path with~
.<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>me.myname.launchmyservice</string> <key>ProgramArguments</key> <array> <string>/Users/myusername/Library/LaunchAgents/me.myname.launchmyservice.sh</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
Save the text file to
~/Library/LaunchAgents/me.myname.update-desktop-from-webcam.plist
– the name should match the "Label" key in the file.-
Load it by issuing the following command:
launchctl load ~/Library/LaunchAgents/me.myname.update-desktop-from-webcam.plist