El comando spawn nos permite invocar
ejecutables externos desde qutebrowser. Nada especial por aquí...
Pero con la opción --userscript, el comando se
vuelve interesante. El ejecutable pasa a ser tratado como un "userscript"
y puede leer ciertas variables de entorno y ejecutar otros comandos
dentro de qutebrowser.
¿Qué puede leer el userscript?
QUTE_MODE: Either hints (started via hints)
or command (started via command or key binding).
QUTE_USER_AGENT: The currently set user
agent, if customized.
QUTE_FIFO: The FIFO or file to write
commands to.
QUTE_HTML: Path of a file containing the
HTML source of the current page.
QUTE_TEXT: Path of a file containing the
plaintext of the current page.
QUTE_CONFIG_DIR: Path of the directory
containing qutebrowser’s configuration.
QUTE_DATA_DIR: Path of the directory
containing qutebrowser’s data.
QUTE_DOWNLOAD_DIR: Path of the downloads
directory.
QUTE_COMMANDLINE_TEXT: Text currently in
qutebrowser’s command line.
In command mode:
QUTE_URL: The current URL.
QUTE_TITLE: The title of the current
page.
QUTE_SELECTED_TEXT: The text currently
selected on the page.
In hints mode:
QUTE_URL: The URL selected via hints.
QUTE_SELECTED_TEXT: The plain text of the
element selected via hints.
QUTE_SELECTED_HTML: The HTML of the
element selected via hints.
¿Qué puede escribir el userscript?
Toda linea de texto escrita a la pipe QUTE_FIFO
va a ser interpretada como un comando. Considerando que tenemos comandos
como insert-text,
fake-key y jseval;
podemos hacer algunas cosillas muy interesantes.