Try saving a plist like this as ~/Library/LaunchAgents/utorrent.plist
:
<?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>utorrent</string>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-gjWa</string>
<string>uTorrent</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
It can be loaded with launchctl load ~/Library/LaunchAgents/utorrent.plist
or by logging out and back in.
-W, --wait-apps Blocks until the used applications are closed (even if they were already running).
-j, --hide Launches the app hidden.
-g, --background Does not bring the application to the foreground.
/Applications/uTorrent.app/Contents/MacOS/uTorrent
would display a visible uTorrent window if uTorrent wasn't already running.
Another option might be to add a line like this to crontab:
*/5 * * * * pgrep -xq uTorrent && osascript -e 'launch app "uTorrent"' || open -gja uTorrent
open -gj
shows the main window if uTorrent is open but has no visible windows. launch
shows the main window if uTorrent is not open.
Programs run from crontab are run in the system security / login session. For example Mail can't access keychains if it is opened by cron.
I'd rather have this a comment, but for some reason I can only post answers.
Have a look at LaunchControl: http://www.soma-zone.com/LaunchControl/. While it does not offer a menu item to start/stop services it provides a list of all available launchd jobs, their current status and a way to start/stop them with the click of a button.
EDIT
LaunchControl now does offer a menu item for controlling selected jobs:
Best Answer
In the end I created the following .plist file. It is autoloaded on startup and it will start a
jupiter
notebook and keep it alive.