Question

Let's say I have a Mac application bundle and my executable inside isn't Cocoa/Objective-C based but I use a normal shell script for any good reason:

  • myProgram.app/
    • Contents/
      • MacOS/
        • mainExecutable.sh
      • Resources/

The shell script does some foo before starting a java process with the main program (GUI based).

I now want to receive drop events to the Apps Dock icon in my java process, but that doesn't seem to work.

The shell script neither receives the dropped file(s) as argument list on startup ($0 or $@) nor does it receive any input on stdin.

How can I pass the drop events and the list of dropped files to the shell script and any executed program inside?

Was it helpful?

Solution

After doing long researches I found the answer on the apple mailing list:

All I need to add to the sh script is this line before invoking the java command:

export CFProcessPath="$0"

And this really works like a charm!

This is my final code:

...
export CFProcessPath="$0"
exec java -jar ...

And as the question on the apple mailing list was another one, this not only works for handling drop events in the shell script but also for supporting OSX System Services thru JNI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top