user202729 / plover_run_shell

Run a shell command from Plover.
GNU General Public License v3.0
5 stars 0 forks source link

A way to insert shell command output as the result? #4

Open alesya-h opened 2 years ago

alesya-h commented 2 years ago

Hi. This plugin is great, but it would be awesome to have a second command that'd insert the stdout as a translation of the stroke. I tried adding

import subprocess

def shell_cmd_out(_: 'plover.engine.StenoEngine', command: str):
    '''
    Command to execute a shell command.
    :param _: The Plover engine that is executing the command.
    :param command: The command to execute.
    '''
    return(subprocess.check_output(command,shell=True,text=True))

and adding shell_out = plover_run_shell:shell_cmd_out to entry_points.txt, but that doesn't seem to work. I'm new to both Plover and Python, so I'm not sure I can figure it out on my own. It'd be great if you can help with this.

user202729 commented 2 years ago

Not a bad idea. Will consider.

(might be a bit slow though because spawning a process has certain overhead)