Inkscape.org
Creating New Extensions Extension bash script does not execute
  1. #1
    steve-sims steve-sims @steve-sims

    I'm writing my first Inkscape extension, only problem is that it silently fails to execute :-/

    I'm an experienced developer. Inkscape is 0.92.3 (with some minor code tweaks but unrelated to this). Platform is Ubuntu 16.04 VM.

    I'm developing in the user directory ~/.config/inkscape/extensions but tried copying to the main extensions directory and had the same (non) result.

    My inx file specifies its own submenu, and number of params (ints and a radio optiongroup). In inkscape I can open the dialog from the menu, the params widgets work and save my selections to my preferences file, so everything seems to load ok. I deliberately introduced a dependency error at one point (as a test) and it logged to extension-errors.log as expected.

    So far so good, but when I click "Apply" on the dialog, nothing happens. At the moment the extension script just parses the options and copies the svg tmp file to stdout, while logging diags to a separate file. The dialog stays open, the log file never gets created, and there is nothing in extension-errors.log, so it seems my script is not being executed at all on "Apply".

    The script is in bash. These are relevant lines in my inx:

      <dependency type="executable" location="extensions">mtr_steps.sh</dependency>

        <script>
          <command reldir="extensions" interpreter="bash">mtr_steps.sh</command>
        </script>

    I can post the whole inx if needed but I guess I'm missing something in this part. I assume reldir should also search the user extensions directory (and copying to main extensions as a test did not help). Perhaps interpreter="bash" is not supported in 0.92? I did also try using "shell", but no improvement. Oh, and yes the script has execute permission.

    Any tips appreciated. I'm struggling to get further in the absence of any diags. Have not found any Inkscape logs apart from stdout and extension-errors.log.

  2. #2
    inklinea inklinea @inklinea⛰️

    I use Ubuntu 20.10 and Inkscape 1.1

    I can't really test 16.04 and 0.92

    This works for me: 

    <?xml version="1.0" encoding="UTF-8"?>
    <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
        <name>Shell Script</name>
        <id>org.inkscape.example.sh_test</id>
    
        <effect>
            <object-type>path</object-type>
            <effects-menu>
                <submenu name="Shell Test"/>
            </effects-menu>
        </effect>
        <script>
            <command location="inx" interpreter="shell">sh_test.sh</command>
        </script>
    </inkscape-extension>
  3. #3
    steve-sims steve-sims @steve-sims

    @inklinea thank you for the working example. Showed me straight away that I blundered by having the script tag inside the effect tag. Duh.

    Fixed that and hey presto it works as expected. Yesterday I finished the script and tested standalone, now working as an extension which will be a huge time saver for me.

    We have some complex svg-wrapped-in-xhtml displays (used in a large railway power control system) with up to 100 layers that can show/hide to reconfigure the display at runtime based on scanned external inputs. Setting a particular "step" at edit time by manual show/hide layers was a real pain, now just a couple of clicks 😁

    I will be handling over the development of these displays to a new starter soon, so I'll feel less guilt now.

    Now I need to work out how to mark this as "solved".

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Extension bash script does not execute