This article might give you some ideas on how to code calling the macro from within a bash script.
Also, in OO.o Base, go to Help. In the Index search field, enter "Basic" and select the item "scripting". Then scroll down to "to assign a script to an event". That information might also be helpful.