qute: Update bookmarklets and config structure

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).
This commit is contained in:
Marty Oehme 2021-04-22 11:07:49 +02:00
parent 7d959248cd
commit f7350756d0
Signed by: Marty
GPG key ID: B7538B8F50A1C800
8 changed files with 623 additions and 166 deletions

View file

@ -0,0 +1,33 @@
c.aliases["gem"] = "hint links userscript qute-gemini"
# Use q for quitting a tab (mimicks vim buffer) - qa is used for exiting
c.aliases["q"] = "tab-close"
# if we save sessions with w, load sessions with e (again, mimicks vim)
c.aliases["e"] = "session-load"
# wallabag add current page, either with walla command, or <leader>bw
c.aliases["add-wallabag"] = "spawn --userscript wallabag_add.sh"
# add to (my) shaarli instance
c.aliases["add-shaarli"] = "spawn --userscript shaarli_add.sh"
# re-opens the current page on the web archive overview page
c.aliases["send-to-archive"] = "open https://web.archive.org/web/{url}"
# sends current page to outline and thus through readability mode
c.aliases["send-to-outline"] = "open https://outline.com/{url}"
# save current page to pdf file
c.aliases["save_to_pdf"] = "spawn --userscript pagetopdf.sh"
# translate current page / selection with google translate
c.aliases["translate-page-google"] = "spawn --userscript translate_google.sh"
c.aliases[
"translate-selection-google"
] = "spawn --userscript translate_google.sh --text"
# print picture of current url as qr code
c.aliases["show-qr"] = "spawn --userscript qr"
# add a task of current page to taskwarrior
c.aliases["taskadd"] = "spawn --userscript taskadd"

View file

@ -11,20 +11,39 @@ from qutebrowser.config.configfiles import ConfigAPI # noqa: F401
# load additional settings configured via autoconfig.yml
config.load_autoconfig()
## CHANGING DEFAULTS
# rebind moving tabs to free for download
config.bind("gG", "tab-give")
# switch binds for scroll-marks and quick-/book-marks
config.bind("m", "mode-enter set_mark")
config.bind("`", "quickmark-save")
config.bind("~", "bookmark-add")
c.completion.web_history.max_items = 1000
c.hints.uppercase = True
c.editor.command = ["alacritty", "-e", "nvim", "-f", "{file}"]
c.editor.command = [
"alacritty",
"-e",
"nvim",
"-f",
"{file}",
"-c",
"normal {line}G{column0}l",
]
# LOOK
# ----
# change filepicker
c.fileselect.handler = "external"
picker = [
"alacritty",
"--class",
"floating,floating",
"-e",
"vifm",
"--choose-files",
"{}",
]
c.fileselect.single_file.command = picker
c.fileselect.multiple_files.command = picker
c.downloads.location.directory = os.getenv("XDG_DOWNLOAD_DIR", "~/downloads")
c.downloads.location.prompt = False
config.source("alias.py")
config.source("keys.py")
config.source("content.py")
config.source("url.py")
# Tab-Bar
# have tab bar on the right, not on the top
@ -35,166 +54,17 @@ c.tabs.width = "15%"
c.colors.webpage.bg = "#555555"
# FUNCTION
# --------
# Prevents *all* tabs from being loaded on restore, only loads on activating them
c.session.lazy_restore = True
# Binds
# 'Leader' key binding
leader = "<Space>"
# toggles ('cycles') between tabs always showing, or only when switching between them
config.bind(
leader + "tt",
"config-cycle -t tabs.show always switching ;; config-cycle -t statusbar.show in-mode always",
)
config.bind(leader + "th", "set tabs.position bottom")
config.bind(leader + "tH", "set tabs.position top")
config.bind(leader + "tv", "set tabs.position right")
config.bind(leader + "tV", "set tabs.position left")
# [M]edia shortcuts - watch, queue, download media
# bind mpv to play the current page/links, using a single instance which queues the next link passed
config.bind(leader + "M", "spawn umpv {url}")
config.bind(leader + "m", "hint links spawn umpv {hint-url}")
# bind youtube-dl to download the current page/links
config.bind(leader + "dM", "spawn vidl {url}")
config.bind(
leader + "dm",
"hint --rapid links spawn vidl {hint-url}",
)
# save current page to pdf file
c.aliases["save_to_pdf"] = "spawn --userscript pagetopdf.sh"
# set to gp, to mirror gd (download) just as go-Pdfdownload
config.bind(leader + "dp", "save_to_pdf", mode="normal")
# open last download
config.bind("gD", "download-open")
# Use q for quitting a tab (mimicks vim buffer) - qa is used for exiting
c.aliases["q"] = "tab-close"
# if we save sessions with w, load sessions with e (again, mimicks vim)
c.aliases["e"] = "session-load"
# bookmarklet aliases:
# Bookmarklets get assigned to ", mirroring the opening of marks, but not interfering
# with scroll-marks (which are really useful!)
# wallabag add current page, either with walla command, or <leader>bw
c.aliases["add-wallabag"] = "spawn --userscript wallabag_add.sh"
config.bind('"w', "add-wallabag", mode="normal")
# add to (my) shaarli instance
c.aliases["add-shaarli"] = "spawn --userscript shaarli_add.sh"
config.bind('"s', "add-shaarli", mode="normal")
# re-opens the current page on the web archive overview page
c.aliases["send-to-archive"] = "open https://web.archive.org/web/{url}"
config.bind('"a', "send-to-archive", mode="normal")
# sends current page to outline and thus through readability mode
c.aliases["send-to-outline"] = "open https://outline.com/{url}"
config.bind('"o', "send-to-outline", mode="normal")
# translate current page / selection with google translate
c.aliases["translate-page-google"] = "spawn --userscript translate_google.sh"
c.aliases[
"translate-selection-google"
] = "spawn --userscript translate_google.sh --text"
config.bind('"g', "translate-page-google", mode="normal")
config.bind('"G', "translate-selection-google", mode="normal")
# print picture of current url as qr code
c.aliases["show-qr"] = "spawn --userscript qr"
config.bind('"q', "show-qr")
# set stylesheets for the browser to use
# leader - ss to remove all applied stylesheets
config.bind(
leader + "s",
"config-cycle content.user_stylesheets " + 'stylesheets/stylesheet.css ""',
)
# Enable and disable javascript
config.bind(leader + "js", "config-cycle content.javascript.enabled true false")
# Reload this config
config.bind(leader + "VV", "config-source")
c.url.searchengines = {
"DEFAULT": "https://search.martyoeh.me/?q={}",
"l": "https://links.martyoeh.me/?searchterm={}&searchtags=",
"ddg": "https://duckduckgo.com/?q={}",
"d": "https://www.dict.cc/?s={}",
"t": "https://www.thesaurus.com/browse/{}",
"gt": "https://translate.google.com/#auto/de/{}",
"dt": "https://www.deepl.com/translator#en/de/{}",
"g": "https://www.google.com/search?q={}",
"r": "https://old.reddit.com/r/{}",
"w": "https://en.wikipedia.org/w/index.php?search={}",
"gh": "https://github.com/search?q={}",
"al": "https://wiki.archlinux.org/index.php/{}",
"aur": "https://aur.archlinux.org/packages/?K={}",
"yt": "https://www.youtube.com/results?search_query={}",
"maps": "https://www.google.fr/maps?q={}",
"gol": "https://golang.org/pkg/{}/",
"man": "https://manned.org/browse/search?q={}",
"lib": "http://libgen.fun/search.php?req={}",
"sci": "https://sci-hub.do/{}",
"alt": "https://alternativeto.net/software/{}/?license=opensource",
"hn": "https://hn.algolia.com/?q={}",
"kb": "https://soeg.kb.dk/discovery/search?query=any,contains,{}&tab=Everything&search_scope=MyInst_and_CI&vid=45KBDK_KGL:KGL&offset=0&lang=en",
}
c.content.blocking.enabled = True
c.content.blocking.method = "both"
c.content.blocking.adblock.lists = [
"http://www.malwaredomainlist.com/hostslist/hosts.txt",
"http://someonewhocares.org/hosts/hosts",
"http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext",
"https://secure.fanboy.co.nz/fanboy-cookiemonster.txt",
# for code_select.py userscript
# Allows copying code sections to clipboard easily
c.hints.selectors["code"] = [
# Selects all code tags whose direct parent is not a pre tag
":not(pre) > code",
"pre",
]
c.content.blocking.hosts.lists = [
"http://winhelp2002.mvps.org/hosts.zip",
"http://malwaredomains.lehigh.edu/files/justdomains.zip",
]
c.content.blocking.whitelist = ["piwik.org"]
c.content.autoplay = False
c.content.pdfjs = False
c.content.javascript.enabled = False
js_whitelist = [
"*://*.youtube.com/*",
"*://127.0.0.1/*",
"*://asciinema.org/*",
"*://calendar.google.com/*",
"*://clockify.me/tracker*",
"*://darksky.net/*",
"*://deepl.com/*",
"*://duckduckgo.com/*",
"*://fosstodon.org/*",
"*://github.com/*",
"*://gitlab.com/*",
"*://localhost/*",
"*://mail.google.com/*",
"*://maps.google.com/*",
"*://*.martyoeh.me/*",
"*://news.ycombinator.com/*",
"*://old.reddit.com/*",
"*://todoist.com/*",
"*://toggl.com/*",
"*://translate.google.com/*",
"chrome://*/*",
"file://*",
"qute://*/*",
]
for page in js_whitelist:
with config.pattern(page) as p:
p.content.javascript.enabled = True
# give the browser nice theme colors
config.source("colorscheme.py")

View file

@ -0,0 +1,44 @@
c.content.blocking.enabled = True
c.content.blocking.method = "both"
c.content.blocking.adblock.lists = [
"http://www.malwaredomainlist.com/hostslist/hosts.txt",
"http://someonewhocares.org/hosts/hosts",
"http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext",
"https://secure.fanboy.co.nz/fanboy-cookiemonster.txt",
]
c.content.blocking.hosts.lists = [
"http://winhelp2002.mvps.org/hosts.zip",
"http://malwaredomains.lehigh.edu/files/justdomains.zip",
]
c.content.blocking.whitelist = ["piwik.org"]
c.content.autoplay = False
c.content.pdfjs = False
c.content.javascript.enabled = False
js_whitelist = [
"*://*.youtube.com/*",
"*://127.0.0.1/*",
"*://asciinema.org/*",
"*://calendar.google.com/*",
"*://clockify.me/tracker*",
"*://darksky.net/*",
"*://deepl.com/*",
"*://duckduckgo.com/*",
"*://fosstodon.org/*",
"*://github.com/*",
"*://gitlab.com/*",
"*://localhost/*",
"*://mail.google.com/*",
"*://maps.google.com/*",
"*://*.martyoeh.me/*",
"*://news.ycombinator.com/*",
"*://old.reddit.com/*",
"*://todoist.com/*",
"*://toggl.com/*",
"*://translate.google.com/*",
"chrome://*/*",
"file://*",
"qute://*/*",
]
for page in js_whitelist:
with config.pattern(page) as p:
p.content.javascript.enabled = True

View file

@ -0,0 +1,73 @@
# Key mappings
# 'Leader' key binding
leader = "<Space>"
## CHANGED DEFAULTS
# rebind moving tabs to free for download
config.bind("gG", "tab-give")
# switch binds for scroll-marks and quick-/book-marks
config.bind("m", "mode-enter set_mark")
config.bind("`", "quickmark-save")
config.bind("~", "bookmark-add")
## ADDED
# toggles ('cycles') between tabs always showing, or only when switching between them
config.bind(
leader + "tt",
"config-cycle -t tabs.show always switching ;; config-cycle -t statusbar.show in-mode always",
)
config.bind(leader + "th", "set tabs.position bottom")
config.bind(leader + "tH", "set tabs.position top")
config.bind(leader + "tv", "set tabs.position right")
config.bind(leader + "tV", "set tabs.position left")
# [M]edia shortcuts - watch, queue, download media
# bind mpv to play the current page/links, using a single instance which queues the next link passed
config.bind(leader + "M", "spawn umpv {url}")
config.bind(leader + "m", "hint links spawn umpv {hint-url}")
# bind youtube-dl to download the current page/links
config.bind(leader + "dM", "spawn vidl {url}")
config.bind(
leader + "dm",
"hint --rapid links spawn vidl {hint-url}",
)
# Download shortcuts
config.bind(leader + "dd", "download", mode="normal")
config.bind(leader + "dp", "save_to_pdf", mode="normal")
# open last download
config.bind("gD", "spawn --userscript open_download")
config.bind('"w', "add-wallabag", mode="normal")
config.bind('"s', "add-shaarli", mode="normal")
config.bind('"a', "send-to-archive", mode="normal")
config.bind('"o', "send-to-outline", mode="normal")
config.bind('"g', "translate-page-google", mode="normal")
config.bind('"G', "translate-selection-google", mode="normal")
config.bind('"q', "show-qr")
config.bind(leader + "r", "spawn --userscript readability")
# set stylesheets for the browser to use
config.bind(
leader + "s",
"config-cycle content.user_stylesheets " + 'stylesheets/stylesheet.css ""',
)
config.bind(leader + "a", "set-cmd-text -s :taskadd")
# Enable and disable javascript
config.bind(leader + "js", "config-cycle content.javascript.enabled true false")
# Reload configuration
config.bind(leader + "VV", "config-source")
# Enable code snippet hinting mode
config.bind(";c", "hint code userscript code_select.py")
# first looks if it's a gemini link and then fall back to http
config.bind(";g", "hint links userscript qute-gemini")
config.bind(";G", "hint links userscript qute-gemini-tab")

View file

@ -0,0 +1,26 @@
c.url.searchengines = {
"DEFAULT": "https://search.martyoeh.me/?q={}",
"l": "https://links.martyoeh.me/?searchterm={}&searchtags=",
"ddg": "https://duckduckgo.com/?q={}",
"d": "https://www.dict.cc/?s={}",
"t": "https://www.thesaurus.com/browse/{}",
"gt": "https://translate.google.com/#auto/de/{}",
"dt": "https://www.deepl.com/translator#en/de/{}",
"g": "https://www.google.com/search?q={}",
"r": "https://old.reddit.com/r/{}",
"w": "https://en.wikipedia.org/w/index.php?search={}",
"gh": "https://github.com/search?q={}",
"al": "https://wiki.archlinux.org/index.php/{}",
"aur": "https://aur.archlinux.org/packages/?K={}",
"yt": "https://www.youtube.com/results?search_query={}",
"maps": "https://www.google.fr/maps?q={}",
"gol": "https://golang.org/pkg/{}/",
"man": "https://manned.org/browse/search?q={}",
"lib": "http://libgen.fun/search.php?req={}",
"#sci": "https://sci-hub.do/{}",
"alt": "https://alternativeto.net/software/{}/?license=opensource",
"hn": "https://hn.algolia.com/?q={}",
"kb": "https://soeg.kb.dk/discovery/search?query=any,contains,{}&tab=Everything&search_scope=MyInst_and_CI&vid=45KBDK_KGL:KGL&offset=0&lang=en",
}
c.url.default_page = "https://start.duckduckgo.com"
c.url.start_pages = ["https://start.duckduckgo.com"]