I have a couple instances in which I cannot seem to be able to run subprocesses from within an Inkscape extension. One is this case:
def close_dialog(self, name=None):
try:
result = subprocess.run(["wmctrl", "-lG"], capture_output=True, text=True).stdout
w_id = re.sub(r's.+', '', [ line for line in result.split('n') if self.options.name in line][0]).strip()
result = subprocess.run(["wmctrl", "-v", "-i", "-c", w_id ], shell=False, capture_output=True, text=True)
result = subprocess.run(["wmctrl", "-v", "-c", self.options.name], shell=False, capture_output=True, text=True)
except Exception as e:
self.print_to_tty(e)
which gets called from within the effect:
def effect(self):
p = subprocess.run(['xclip', '-o'], input=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=5)
self.add_text(p.stdout, separate=True)
self.close_dialog()
return
but does not close any window. If I skip the line containing self.add_text
or any other line manipulating the svg output, it works ok
The other instance is
def paste_into_clipboard(self, text):
p = subprocess.Popen(['xclip', '-selection', 'primary', '-f'], stdin=subprocess.PIPE)
p.stdin.write(text.encode())
p.stdin.close()
which hangs forever.
Any subprocess taking input from the clipboard seems to work fine, and so apparently do subprocesses not involving wmctrl
or feeding into xclip
– but I would not know if that’s a fact.
Any idea as to why these don’t work?