Difference between revisions of "Batch Jobs"

From Freeplane - free mind mapping and knowledge management software
(Notes)
Line 24: Line 24:
 
* On Windows type
 
* On Windows type
  
   freeplane.bat -X$OpenAction$0
+
   freeplane.bat -XOpenAction
  
 
* on Linux type (note that the dollar signs have to be quoted)
 
* on Linux type (note that the dollar signs have to be quoted)
 +
 +
  ./freeplane.sh -XOpenAction
 +
 +
* before Freeplane 1.5 menu action keys contained dollar signs and on Linux you had to protect these via single quotation marks:
  
 
   ./freeplane.sh -X'$OpenAction$0'
 
   ./freeplane.sh -X'$OpenAction$0'
Line 33: Line 37:
 
Scripts have their menu items too so most of the steps also hold for scripts.
 
Scripts have their menu items too so most of the steps also hold for scripts.
  
* Find the command line option as written above. Let's assume the command line parameter is -X$MyScript_on_single_node$0
+
* Find the command line option as written above. Let's assume the command line parameter is -XMyScript_on_single_node
  
 
* On Windows type
 
* On Windows type
  
   freeplane.bat -S -N -X$MyScript_on_single_node$0
+
   freeplane.bat -S -N -XMyScript_on_single_node
  
 
* on Linux type
 
* on Linux type
  
   ./freeplane.sh -S -N -X'$MyScript_on_single_node$0'
+
   ./freeplane.sh -S -N -XMyScript_on_single_node
  
 
* Option ''-S'' makes Freeplane stop/shutdown after executing the script.
 
* Option ''-S'' makes Freeplane stop/shutdown after executing the script.
Line 51: Line 55:
  
 
===Notes===
 
===Notes===
* Options without an argument can be combined with others like -SMX'$MyScript_on_single_node$0'
+
* Options without an argument can be combined with others like -SMX'MyScript_on_single_node'
  
* If you want to execute more than one menu item use the -X option multiple times.
+
* If you want to execute more than one menu item use the -X option multiple times. Each item will be executed in the order given on the command line.
  
 
* The "single instance" preferences (Environment->Single program instance) are ignored for batch jobs since the other instance may not be able to handle all commands properly. If you for instance have given the command to exit after executing the options you might not be aware that you would terminate the single instance.
 
* The "single instance" preferences (Environment->Single program instance) are ignored for batch jobs since the other instance may not be able to handle all commands properly. If you for instance have given the command to exit after executing the options you might not be aware that you would terminate the single instance.
  
 
[[Category:Advanced]][[Category:Script]]
 
[[Category:Advanced]][[Category:Script]]

Revision as of 16:53, 6 November 2016

Freeplane is a program with a graphical user interface. - That's smart since it would be hard to create mindmaps otherwise...

But there are some cases where you might want to let Freeplane do something for you unattended especially if you have appropriate scripts. So here's what Freeplane supports in this respect:

  • Open the GUI, execute one or more functions and exit afterwards,
  • Execute one or more function and keep the Freeplane window opened.

All is build on two building blocks:

  • All functions in the menu (e.g. scripts) are available for batch execution.
  • The functions are submitted to Freeplane on the command line.

Howto

Preparation

Install Freeplane stable and a recent Developer Tools add-on. Then restart Freeplane.

Run a function on startup

Let's assume that you want to launch the "Open saved map..." function whenever you start Freeplane. This is how it works:

  • Start Freeplane and invoke Tools > Developer Tools > Menu item info
  • In the dialog select File > Open saved map... and click OK.
  • The necessary command line argument that is printed after "Command line option:" has been copied to the clipboard.
  • Open a command line window. If the Freeplane executables are not in the path variable you have to cd to the directory where freeplane.bat (on Windows) or freeplane.sh (on Linux) reside.
  • On Windows type
 freeplane.bat -XOpenAction
  • on Linux type (note that the dollar signs have to be quoted)
 ./freeplane.sh -XOpenAction
  • before Freeplane 1.5 menu action keys contained dollar signs and on Linux you had to protect these via single quotation marks:
 ./freeplane.sh -X'$OpenAction$0'

Run a script and terminate

Scripts have their menu items too so most of the steps also hold for scripts.

  • Find the command line option as written above. Let's assume the command line parameter is -XMyScript_on_single_node
  • On Windows type
 freeplane.bat -S -N -XMyScript_on_single_node
  • on Linux type
 ./freeplane.sh -S -N -XMyScript_on_single_node
  • Option -S makes Freeplane stop/shutdown after executing the script.
  • Option -N let's Freeplane set the system variable nonInteractive variable to true. It's upto the script to evaluate this variable like this:
 boolean isInteractive() {
     return !Boolean.parseBoolean(System.getProperty("nonInteractive"))
 }

Notes

  • Options without an argument can be combined with others like -SMX'MyScript_on_single_node'
  • If you want to execute more than one menu item use the -X option multiple times. Each item will be executed in the order given on the command line.
  • The "single instance" preferences (Environment->Single program instance) are ignored for batch jobs since the other instance may not be able to handle all commands properly. If you for instance have given the command to exit after executing the options you might not be aware that you would terminate the single instance.