title: How to Listen For an Application Launch Event in Mac OS X?
body: <p>I wrote an <code>AppleScript</code> to mount a <code>SparseBundle</code> image and I want it to be executed exactly when <code>Time Machine</code> launches.</p>
  
  <p>Right now, I periodically check if Time Machine is running with <code>AppleScript</code> using <code>on idle</code> statement:</p>
  
  <pre><code>on idle
      ....
      return &lt;interval&gt;
  end idle
  </code></pre>
  
  <p>which isn't a robust way. In my opinion adding an event trigger for <code>Application Launch</code> event would be a better approach.</p>
  
  <p>Could you please help?</p>
  
  <p>An <code>Objective-C</code> or <code>Python</code> sample code (I'd prefer <code>Python</code>) is more than welcome.</p>