Command plugin for Plover to run an arbitrary Python command.
Project description
plover-run-py
Command plugin for Plover to run an arbitrary Python command.
Warning: While this plugin can do everything what a command plugin can, this should only be used for personal usage. If the usage is sufficiently general, it's recommended to make a Plover command plugin instead.
It's also possible to execute a command from the command-line, using
the plover_send_command
script.
Unfortunately, this method takes about 1.5s per call due to Plover's overhead.
If python -m plover.scripts.send_command
is used, the time is reduced to 0.3s per call,
mostly because of pkg_resources
import.
See also
plover-run-shell
plugin for running a shell command.plover-debugging-console
plugin for running Python commands in Plover in a shell (more convenient for debugging and showing results).plover-retro-stringop
plugin for running Python commands to transform/modify the previous text using arbitrary Python expression.
Usage
In order to use this plugin in Plover you need to create a dictionary entry of the form:
{
"example_stroke": "{PLOVER:PY:command}"
}
Variables engine
and plover
are provided.
Remember to escape the characters in \{}
according to Plover's dictionary format.
Alternatively, if the definition has the form "{PLOVER:PY_F:path}"
, the content of the file
at the given path will be run as Python code.
Note: If the command takes a long time to finish, Plover might freeze.
Example
Refer to the API reference (1, 2) (unofficial, community-maintained) for more details.
-
Sleep between key presses:
{#a}{plover:py:import time; time.sleep(1)}{#b}
-
Toggle a plugin and show a warning notification on the status: (broken into multiple lines for readability) See also user202729/plover-delay: Plover command plugin to sleep for some time. for a dedicated plugin.
{plover:py: engine["enabled_extensions"]^=\{'ibus'\}; plover.log.warning('ibus enabled=' + str('ibus' in engine["enabled_extensions"])) }
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for plover_run_py-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69690aa0836d74eac07d63c94487ffb9d6eb3226db3e2236eb2bc52f8484ba7d |
|
MD5 | bd649661004b9fae4e186b7a4edc62dd |
|
BLAKE2b-256 | b530ae3cd165388da0f82fa40e8e98faf392d6bb4d3fb976905a86b6c857cc65 |