Can triggers be set up so that when "App A" starts, another "App B" gets started automatically? Ideally, the solution would send a quit message to "App B" when "App A" quits, but the important part is the launch sequence.

1 Answer 1


Save a plist like this as ~/Library/LaunchAgents/test.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
<plist version="1.0">
    <string>while sleep 5; do
  if pgrep -x Preview; then
    pgrep -x TextEdit || open -jga TextEdit
    pgrep -x TextEdit &amp;&amp; osascript -e 'quit app "TextEdit"'

Then load the plist with launchctl load ~/Library/LaunchAgents/test.plist or by logging out and back in.

open -jg is supposed to open an application hidden and without raising any windows. For some document-based applications like TextEdit, it opens a new visible window if the application is open but has no visible windows.

pgrep and the -j option for open were added in 10.8. The -j option is only shown in the help message and not on the man page.

You must log in to answer this question.

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