I’ve switched to linux recently (CachyOS - KDE Plasma) and I’m trying to recreate some of my AutoHotKey scripts in bash. What I want it to do is ask for a name, create a certain directory structure, open a Writer template and save the file with the name inputted. With AHK I used the mouse functions to jerry-rig the thing together, but I don’t think I can do the same here.
I’ve managed to create almost everything I need, except saving the file. I’m using libreoffice -n /pathj/to/template/Template.ott and that opens writer with the desired template, but how can I save it from there? I read the documentation and found the -invisible and -headless options, but they lead to an API page which is waaay above what a racecar johhny user like me can figure out. Is there an easier command I’m missing here? Or can anyone suggest any workaround that does more or less the same? I tried touch MyVar.odt but I couldn’t force this one to use a template.
Thanks for the suggestion. I tried that one before going with bash, but development for it has stalled and I use Wayland instead of X11. I settled for a simpler bash script for the moment. Maybe when I have the time I’ll look into the API documentation and see if I can improve it in any way.
In the end that’s what I had to do. Copy the template, rename it into what I want, convert from .ott to .odt, delete the .ott. It’s a hack job, but it’s the only thing I could do. I’d still like to write the title inside the .odt file, but apparently that’s way above what I can manage and I just went back to doing manually.
Running a macro from libreoffice command line - #2 by fpy
Macros/Basic/Documents - The Document Foundation Wiki
etc …
AI can probably wrap it up your way,
Still to complicated, if all you want do change is the name of the file and your task is to
What I do for a new project:
- I created a model/template directory tree including all needed files. At this time I also created a .odt (in my case .ods) ftom my template.
- For a new project all I need to do is to copy the folder. Even manual that’s very quick and simple but you can create a script for this.
- I some places I use a script to replace/rename placeholders like MONTH with current values, but mostly I prefer to have the current project in a folder named “active” and to move that to archve-nnnn when closed.
- Inside LibreOffice I prefer to use Fields (used for example by serial letters) and if you need simple scripting you could create a simple csv as datasource to fill the fields. (I prefer now a sqlite-database for the same type of jobs.)
Personally I idn’t use a BATCH or a Bash script for years.
If I needed somthing of the kind, (and wanted to make it platform independent, of course), I created a littel Calc file containing the few lines of Basic for automation, and opened it to start the respective process when needed.
A sheet contained in that “batch in disguise” can then be used to set the actual parameters for the call.