I want to write a linux bash script to control the behaviour of inkscape and to manipulate a drawing from the script. Within the script I first start inkscape with a file and then I want to open the document settings dialog. These 2 lines look like that:
inkscape -f $mp_file
inkscape $mp_file --verb=DialogDocumentProperties
but what happens is that the second code line opens a new instance of inkscape with the file again. (It works when writing both commands into one line, but I have to add a third, fourth,... line, which I cannot concatenate as I have to do some other work between these commands.)
Thus my question: is there a way to use the first instance of inkscape with further --verb-attributes?
OK, I have the following task: I open $mp_file in inkscape, open the Document Dialog Properties window, fill in a new paper format (as shown below with xdotool), close the documents properties window again, move my objects a little bit to fit into the new paper format and finally print it. At the moment, all these commands I do with xdotool, which sends keystroke commands to the active window and which looks like this (sorry, my comments are a lot in German as is my GUI, but I think that this would not disturb you):
mp_IDDoc=`xdotool search --sync --name Dokumenteinstellungen` xdotool windowactivate $mp_IDDoc xdotool key Tab Tab Tab Tab Tab # tab to the Breite entry field xdotool type $mp_coordx # enter a new Breite for A5 sleep 1 xdotool key Tab # tab to the Höhe entry field xdotool type $mp_coordy # enter the new Höhe xdotool key ctrl+w # close the Dokumenteinstellungen window sleep 2 xdotool windowactivate --sync $mp_IDInk # activate the original inkscape window again; don't know if needed, but I do it xdotool key F1 # select the select tool xdotool key ctrl+a # select all sleep 1 xdotool key alt+x # move to X-coordinate field in tools control bar xdotool key Delete # delete present value xdotool key $mp_coordx # enter the new X-coordinate sleep 1 xdotool key Tab # move to Y-coordinate field xdotool key Delete xdotool key $mp_coordy # enter the new Y-coordinate xdotool key Return # confirm entries xdotool key 5 # show page to be able to watch life what happens sleep 2 # give some time for the mass of objects to be moved xdotool key ctrl+p # print
As you see, the task between document properties window and printing is also controlled by my script. The code - I think - only works as I have added some sleeping seconds for inkscape to react, i.e. xdotool can send keystrokes to inkscape, but I do not know, wherher they really reach the correct place at the correct time.
I want to write a linux bash script to control the behaviour of inkscape and to manipulate a drawing from the script. Within the script I first start inkscape with a file and then I want to open the document settings dialog. These 2 lines look like that:
inkscape -f $mp_file
inkscape $mp_file --verb=DialogDocumentProperties
but what happens is that the second code line opens a new instance of inkscape with the file again. (It works when writing both commands into one line, but I have to add a third, fourth,... line, which I cannot concatenate as I have to do some other work between these commands.)
Thus my question: is there a way to use the first instance of inkscape with further --verb-attributes?
Thanks
RoXus
> I have to do some other work between these commands
Can you express that in terms of verbs as well? Then you could just do everything in one command.
Otherwise you could check if the shell mode as implemented in upcoming Inkscape 1.0 could be useful for this scenario.
OK, I have the following task: I open $mp_file in inkscape, open the Document Dialog Properties window, fill in a new paper format (as shown below with xdotool), close the documents properties window again, move my objects a little bit to fit into the new paper format and finally print it. At the moment, all these commands I do with xdotool, which sends keystroke commands to the active window and which looks like this (sorry, my comments are a lot in German as is my GUI, but I think that this would not disturb you):
mp_IDDoc=`xdotool search --sync --name Dokumenteinstellungen`
xdotool windowactivate $mp_IDDoc
xdotool key Tab Tab Tab Tab Tab # tab to the Breite entry field
xdotool type $mp_coordx # enter a new Breite for A5
sleep 1
xdotool key Tab # tab to the Höhe entry field
xdotool type $mp_coordy # enter the new Höhe
xdotool key ctrl+w # close the Dokumenteinstellungen window
sleep 2
xdotool windowactivate --sync $mp_IDInk # activate the original inkscape window again; don't know if needed, but I do it
xdotool key F1 # select the select tool
xdotool key ctrl+a # select all
sleep 1
xdotool key alt+x # move to X-coordinate field in tools control bar
xdotool key Delete # delete present value
xdotool key $mp_coordx # enter the new X-coordinate
sleep 1
xdotool key Tab # move to Y-coordinate field
xdotool key Delete
xdotool key $mp_coordy # enter the new Y-coordinate
xdotool key Return # confirm entries
xdotool key 5 # show page to be able to watch life what happens
sleep 2 # give some time for the mass of objects to be moved
xdotool key ctrl+p # print
As you see, the task between document properties window and printing is also controlled by my script. The code - I think - only works as I have added some sleeping seconds for inkscape to react, i.e. xdotool can send keystrokes to inkscape, but I do not know, wherher they really reach the correct place at the correct time.
Thank you for your help
RoXus