Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Quicksilver, which is a nifty program that really speeds up my work. I've set it to launch when I log in.

However, since Snow Leopard, it's become a bit less stable, and once in a while, it crashes. And obviously, it won't restart by itself.

I'm pretty sure I can use launchd to ensure it's always running when I'm logged in. Is there a good guide/example of how to make sure a process restarts when it's killed/terminated/crashed with it?

share|improve this question
up vote 3 down vote accepted

Googling for launchd quicksilver I got this:

http://www.zzamboni.org/brt/2008/01/28/using-launchd-to-immortalize-quicksilver-howto/index.html

...which looks right.

Here's the gist of it in case that page ever goes away:

  • In the QS preferences, disable “start at login”

  • Create a new LaunchAgent in my account by storing the following file as ~/Library/LaunchAgents/org.quicksilver.plist (actually I used Lingon to create the file – very handy utility!):

<?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>
        <true/>
        <key>Label</key>
        <string>org.quicksilver</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Applications/Quicksilver.app/Contents/MacOS/Quicksilver</string>
        </array>
</dict>
</plist>

See man launchd.plist for more information about the keys you can put into a launchd plist file to control when and how launchd launches or re-launches processes.

share|improve this answer
    
Yup, looks right. I'll check it at home later. – zneak Apr 28 '10 at 13:33
    
Works perfectly fine! Thank you. – zneak Apr 29 '10 at 0:39

I have not tried this, as I don't have a mac, but I've been told it has bash as default shell these days. You could possibly get this going with a bash-script that you execute on logon by any means.

What it basically does is execute the given command repeatedly until it returns zero, which means it closed normally.

#!/bin/bash

RETVAL=1
until [ $RETVAL -eq 0 ]; do
    # change this to whatever is used to launch quicksilver
    /Applications/Quicksilver.app/Quicksilver

    RETVAL=$?
done

Edit: To clarify, put that in an empty text-file (optionally with an .sh-extension) and give it execute permissions (chmod +x filename) and it should work.

share|improve this answer
    
That's indeed a solution, though I'd prefer launchd since it's apparently its purpose. (Also, just so you know, executables are located inside the Contents/MacOS folder of an application bundle.) Thanks though, I didn't think about a shell script for the job before you mentioned it. – zneak Apr 27 '10 at 23:16
    
You clearly know nothing about Macs and should refrain from posting anything on the subject. – Hasaan Chop Apr 28 '10 at 1:51
1  
@Hasaan: While I mostly agree with your pointing out my lack of knowledge of macs, I do not see where my possible solution failed. It does what the OP wanted, just not in the way he wanted. For your enjoyment I will refrain from posting possible solutions to future problems, unless the solution in question is what the OP wanted, to the letter. – user32498 Apr 28 '10 at 6:19
    
@Hasaan Chop: You clearly know nothing about what I consider good or not and should refrain from posting anything on the subject. – zneak Apr 28 '10 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .