tags:

views:

26

answers:

0

I've got a script that opens my application using the "open" command. Right now, open is creating a new instance of my app each time it is called.

What I would like to happen is that open would somehow detect that an instance of my app is already running, and then just send that instance the -(BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileName message.

I thought that this was the default behavior, but it is apparently not. Is there a standard way to achieve the behavior I'm looking for?

Here is the script:

#!/usr/bin/env ruby

ENV['PG_CMD_LINE'] = "true"

app_id = "com.mycom.MyApp"
if ARGV.size > 0
 `open -b #{app_id} #{ARGV[0]}`
else
 `open -b #{app_id} #{Dir.getwd}`
end

Is there a relevant portion of the app source code people would like to see? Otherwise I can code up a demo app.