I have often wondered how to automate libreoffice by using xdotool. I know that the window has to be selected out of the window stack, and I tried programming it as a window bash variable under xdotool in the bash script. I then tried sending the next keypress to the window but to no result. Right now I want to pass the ctrl+N command to the libre office window to open a new document.
#!/bin/bash
/usr/bin/libreoffice
mywindow=$(xdotool search --class libreoffice)
xdotool windowactivate $mywindow && xdotool key --window $mywindow Next
xdotool key ctrl+n
I do get an error code
There are no windows in the stack.
Invalid window '%1'
Usage: windowactivate [options] [window=%1]
--sync - only exit once window is active (is visible + active)
If no window is given, %1 is used. See WINDOW STACK in xdotool(1)