qute: Add gemini integration Added simple integration for gemini. When following a link (`f` or `F`) to a page which begins with the `gemini://` protocol, it will automatically convert the page to html and display it instead. qute: Update configuration structure Moved larger setting blocks (cmd aliaes, content settings, key mappings, url settings) into their own files. qute: Add readability, code_select userscripts Added userscript to invoke (python) readability mode which will render the page in a much more nicely to read display. Can be invoked either through `:spawn --userscript readability` or the key combination `<leader>r`. Added userscript to copy code snippets from websites, using the `code` html tag. Invoked through `;c` to fit into the other extended hinting options qutebrowser provides. qute: Add open downloads, default download location Added ability to open last downloads with `gD`, replaces the previous open last download -- this one lets you select with dmenu where the old option only opened the very last download automatically. Set the download directory to default to XDG directory, with fallback to `~/downloads` if the env var is not set. qute: Set vifm filepicker Set vifm to be the filepicker for qute. Can be used to select single or multiple files. Simply select the intended files in vifm and they will be passed through to qutebrowser (and thus whatever website).
54 lines
1.5 KiB
Python
Executable file
54 lines
1.5 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import html
|
|
import re
|
|
import sys
|
|
import xml.etree.ElementTree as ET
|
|
|
|
try:
|
|
import pyperclip
|
|
except ImportError:
|
|
PYPERCLIP = False
|
|
else:
|
|
PYPERCLIP = True
|
|
|
|
|
|
def parse_text_content(element):
|
|
root = ET.fromstring(element)
|
|
text = ET.tostring(root, encoding="unicode", method="text")
|
|
text = html.unescape(text)
|
|
return text
|
|
|
|
|
|
def send_command_to_qute(command):
|
|
with open(os.environ.get("QUTE_FIFO"), "w") as f:
|
|
f.write(command)
|
|
|
|
|
|
def main():
|
|
delimiter = sys.argv[1] if len(sys.argv) > 1 else ";"
|
|
# For info on qute environment vairables, see
|
|
# https://github.com/qutebrowser/qutebrowser/blob/master/doc/userscripts.asciidoc
|
|
element = os.environ.get("QUTE_SELECTED_HTML")
|
|
code_text = parse_text_content(element)
|
|
if PYPERCLIP:
|
|
pyperclip.copy(code_text)
|
|
send_command_to_qute(
|
|
"message-info 'copied to clipboard: {info}{suffix}'".format(
|
|
info=code_text.splitlines()[0],
|
|
suffix="..." if len(code_text.splitlines()) > 1 else "",
|
|
)
|
|
)
|
|
else:
|
|
# Qute's yank command won't copy accross multiple lines so we
|
|
# compromise by placing lines on a single line seperated by the
|
|
# specified delimiter
|
|
code_text = re.sub("(\n)+", delimiter, code_text)
|
|
code_text = code_text.replace("'", '"')
|
|
send_command_to_qute("yank inline '{code}'\n".format(code=code_text))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|