imagej / imagej2

Open scientific N-dimensional image processing :microscope: :sparkler:
https://imagej.net/
BSD 2-Clause "Simplified" License
1.2k stars 337 forks source link

Starting Fiji from command line does interpret arguments only the very first time #241

Closed Michael-Gaehwiler closed 5 years ago

Michael-Gaehwiler commented 5 years ago

=> first time fiji opens and the marco is run. the second time it only shows the already open Fiji instance (good) but does not run the macro (bad)

If I run /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx -macro "some_macro_file.txt" ApplicationID0-, a new instance of Fiji is opened (bad) and the macro is run (good).

What we like to have is, to run macros via terminal but only having one instance of Fiji

ctrueden commented 5 years ago

You can achieve this using the --force-single-instance flag.

Launch one instance using an invocation like:

DEBUG=1 /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx -- --force-single-instance -eval 'print("Hello 1")'

And then launch another one, which will hand off its arguments to the first:

DEBUG=1 /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx -- --force-single-instance -eval 'print("Hello 2")'

The DEBUG=1 is not necessary, but maybe useful to see what's going on with the single instance logic, justt in case there are problems.