commit 7aa6113d0fd32abb81664a8b2779198156d7415f
parent 7b68f7d781ec5ca7499e9b3f1d60ec5008c98507
Author: Janis Pagel <janis.pagel@ims.uni-stuttgart.de>
Date: Tue, 14 Apr 2020 16:02:06 +0200
Add qutebrowser configuration
Diffstat:
3 files changed, 591 insertions(+), 0 deletions(-)
diff --git a/qutebrowser/config.py b/qutebrowser/config.py
@@ -0,0 +1,112 @@
+## Autogenerated config.py
+## Documentation:
+## qute://help/configuring.html
+## qute://help/settings.html
+
+# pylint: disable=C0111
+c = c # noqa: F821 pylint: disable=E0602,C0103
+config = config # noqa: F821 pylint: disable=E0602,C0103
+
+## This is here so configs done via the GUI are still loaded.
+## Remove it to not load settings done via the GUI.
+config.load_autoconfig()
+
+## Aliases for commands. The keys of the given dictionary are the
+## aliases, while the values are the commands they map to.
+## Type: Dict
+c.aliases = {'mpv': 'spawn --userscript qutebrowser_view_in_mpv.bash',
+ 'w': 'session-save',
+ 'q': 'close',
+ 'qa': 'quit',
+ 'wq': 'quit --save',
+ 'wqa': 'quit --save'}
+
+## Always restore open sites when qutebrowser is reopened.
+## Type: Bool
+c.auto_save.session = True
+
+## This setting can be used to map keys to other keys. When the key used
+## as dictionary-key is pressed, the binding for the key used as
+## dictionary-value is invoked instead. This is useful for global
+## remappings of keys, for example to map Ctrl-[ to Escape. Note that
+## when a key is bound (via `bindings.default` or `bindings.commands`),
+## the mapping is ignored.
+## Type: Dict
+c.bindings.key_mappings = {'<Ctrl-[>': '<Escape>',
+ '<Ctrl-6>': '<Ctrl-^>',
+ '<Ctrl-M>': '<Return>',
+ '<Ctrl-J>': '<Return>',
+ '<Shift-Return>': '<Return>',
+ '<Enter>': '<Return>',
+ '<Shift-Enter>': '<Return>',
+ '<Ctrl-Enter>': '<Ctrl-Return>'}
+
+## Allow websites to read canvas elements. Note this is needed for some
+## websites to work properly.
+## Type: Bool
+c.content.canvas_reading = False
+
+## Which cookies to accept.
+## Type: String
+## Valid values:
+## - all: Accept all cookies.
+## - no-3rdparty: Accept cookies from the same origin only. This is known to break some sites, such as GMail.
+## - no-unknown-3rdparty: Accept cookies from the same origin only, unless a cookie is already set for the domain. On QtWebEngine, this is the same as no-3rdparty.
+## - never: Don't accept cookies at all.
+c.content.cookies.accept = 'no-3rdparty'
+
+## Value to send in the `Accept-Language` header. Note that the value
+## read from JavaScript is always the global value.
+## Type: String
+c.content.headers.accept_language = 'en-US,en;q=0.5'
+
+## Custom headers for qutebrowser HTTP requests.
+## Type: Dict
+c.content.headers.custom = {'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
+
+## Validate SSL handshakes.
+## Type: BoolAsk
+## Valid values:
+## - true
+## - false
+## - ask
+c.content.ssl_strict = True
+
+## Enable WebGL.
+## Type: Bool
+c.content.webgl = False
+
+## Editor (and arguments) to use for the `open-editor` command. The
+## following placeholders are defined: * `{file}`: Filename of the file
+## to be edited. * `{line}`: Line in which the caret is found in the
+## text. * `{column}`: Column in which the caret is found in the text. *
+## `{line0}`: Same as `{line}`, but starting from index 0. * `{column0}`:
+## Same as `{column}`, but starting from index 0.
+## Type: ShellCommand
+c.editor.command = ['st', '-e', 'vim', '{file}']
+
+## Search engines which can be used via the address bar. Maps a search
+## engine name (such as `DEFAULT`, or `ddg`) to a URL with a `{}`
+## placeholder. The placeholder will be replaced by the search term, use
+## `{{` and `}}` for literal `{`/`}` signs. The search engine named
+## `DEFAULT` is used when `url.auto_search` is turned on and something
+## else than a URL was entered to be opened. Other search engines can be
+## used by prepending the search engine name to the search term, e.g.
+## `:open google qutebrowser`.
+## Type: Dict
+c.url.searchengines = {'DEFAULT': 'https://duckduckgo.com/?q={}',
+ 'aw': 'https://wiki.archlinux.org/index.php/{}',
+ 'dict': 'https://www.dict.cc/?s={}',
+ 'g': 'https://www.google.de/search?q={}',
+ 'leo': 'https://dict.leo.org/ende?search={}',
+ 'linguee': 'https://www.linguee.com/english-german/search?source=auto&query={}',
+ 'wde': 'https://de.wikipedia.org/wiki/{}',
+ 'wen': 'https://en.wikipedia.org/wiki/{}',
+ 'y': 'https://youtube.com/results?search_query={}',
+ }
+
+## Bindings for normal mode
+config.bind('<Ctrl-M>', 'mpv')
+
+## Load color scheme
+config.source('nord-qutebrowser.py')
diff --git a/qutebrowser/nord-qutebrowser.py b/qutebrowser/nord-qutebrowser.py
@@ -0,0 +1,336 @@
+nord = {
+ # Polar Night
+ 'nord0': '#2e3440',
+ 'nord1': '#3b4252',
+ 'nord2': '#434c5e',
+ 'nord3': '#4c566a',
+ # Snow Storm
+ 'nord4': '#d8dee9',
+ 'nord5': '#e5e9f0',
+ 'nord6': '#eceff4',
+ # Frost
+ 'nord7': '#8fbcbb',
+ 'nord8': '#88c0d0',
+ 'nord9': '#81a1c1',
+ 'nord10': '#5e81ac',
+ # Aurora
+ 'nord11': '#bf616a',
+ 'nord12': '#d08770',
+ 'nord13': '#ebcb8b',
+ 'nord14': '#a3be8c',
+ 'nord15': '#b48ead',
+}
+
+## Background color of the completion widget category headers.
+## Type: QssColor
+c.colors.completion.category.bg = nord['nord0']
+
+## Bottom border color of the completion widget category headers.
+## Type: QssColor
+c.colors.completion.category.border.bottom = nord['nord0']
+
+## Top border color of the completion widget category headers.
+## Type: QssColor
+c.colors.completion.category.border.top = nord['nord0']
+
+## Foreground color of completion widget category headers.
+## Type: QtColor
+c.colors.completion.category.fg = nord['nord5']
+
+## Background color of the completion widget for even rows.
+## Type: QssColor
+c.colors.completion.even.bg = nord['nord1']
+
+## Background color of the completion widget for odd rows.
+## Type: QssColor
+c.colors.completion.odd.bg = nord['nord1']
+
+## Text color of the completion widget.
+## Type: QtColor
+c.colors.completion.fg = nord['nord4']
+
+## Background color of the selected completion item.
+## Type: QssColor
+c.colors.completion.item.selected.bg = nord['nord3']
+
+## Bottom border color of the selected completion item.
+## Type: QssColor
+c.colors.completion.item.selected.border.bottom = nord['nord3']
+
+## Top border color of the completion widget category headers.
+## Type: QssColor
+c.colors.completion.item.selected.border.top = nord['nord3']
+
+## Foreground color of the selected completion item.
+## Type: QtColor
+c.colors.completion.item.selected.fg = nord['nord6']
+
+## Foreground color of the matched text in the completion.
+## Type: QssColor
+c.colors.completion.match.fg = nord['nord13']
+
+## Color of the scrollbar in completion view
+## Type: QssColor
+c.colors.completion.scrollbar.bg = nord['nord1']
+
+## Color of the scrollbar handle in completion view.
+## Type: QssColor
+c.colors.completion.scrollbar.fg = nord['nord5']
+
+## Background color for the download bar.
+## Type: QssColor
+c.colors.downloads.bar.bg = nord['nord0']
+
+## Background color for downloads with errors.
+## Type: QtColor
+c.colors.downloads.error.bg = nord['nord11']
+
+## Foreground color for downloads with errors.
+## Type: QtColor
+c.colors.downloads.error.fg = nord['nord5']
+
+## Color gradient stop for download backgrounds.
+## Type: QtColor
+c.colors.downloads.stop.bg = nord['nord15']
+
+## Color gradient interpolation system for download backgrounds.
+## Type: ColorSystem
+## Valid values:
+## - rgb: Interpolate in the RGB color system.
+## - hsv: Interpolate in the HSV color system.
+## - hsl: Interpolate in the HSL color system.
+## - none: Don't show a gradient.
+c.colors.downloads.system.bg = 'none'
+
+## Background color for hints. Note that you can use a `rgba(...)` value
+## for transparency.
+## Type: QssColor
+c.colors.hints.bg = nord['nord13']
+
+## Font color for hints.
+## Type: QssColor
+c.colors.hints.fg = nord['nord0']
+
+## Font color for the matched part of hints.
+## Type: QssColor
+c.colors.hints.match.fg = nord['nord10']
+
+## Background color of the keyhint widget.
+## Type: QssColor
+c.colors.keyhint.bg = nord['nord1']
+
+## Text color for the keyhint widget.
+## Type: QssColor
+c.colors.keyhint.fg = nord['nord5']
+
+## Highlight color for keys to complete the current keychain.
+## Type: QssColor
+c.colors.keyhint.suffix.fg = nord['nord13']
+
+## Background color of an error message.
+## Type: QssColor
+c.colors.messages.error.bg = nord['nord11']
+
+## Border color of an error message.
+## Type: QssColor
+c.colors.messages.error.border = nord['nord11']
+
+## Foreground color of an error message.
+## Type: QssColor
+c.colors.messages.error.fg = nord['nord5']
+
+## Background color of an info message.
+## Type: QssColor
+c.colors.messages.info.bg = nord['nord8']
+
+## Border color of an info message.
+## Type: QssColor
+c.colors.messages.info.border = nord['nord8']
+
+## Foreground color an info message.
+## Type: QssColor
+c.colors.messages.info.fg = nord['nord5']
+
+## Background color of a warning message.
+## Type: QssColor
+c.colors.messages.warning.bg = nord['nord12']
+
+## Border color of a warning message.
+## Type: QssColor
+c.colors.messages.warning.border = nord['nord12']
+
+## Foreground color a warning message.
+## Type: QssColor
+c.colors.messages.warning.fg = nord['nord5']
+
+## Background color for prompts.
+## Type: QssColor
+c.colors.prompts.bg = nord['nord2']
+
+# ## Border used around UI elements in prompts.
+# ## Type: String
+c.colors.prompts.border = '1px solid ' + nord['nord0']
+
+## Foreground color for prompts.
+## Type: QssColor
+c.colors.prompts.fg = nord['nord5']
+
+## Background color for the selected item in filename prompts.
+## Type: QssColor
+c.colors.prompts.selected.bg = nord['nord3']
+
+## Background color of the statusbar in caret mode.
+## Type: QssColor
+c.colors.statusbar.caret.bg = nord['nord15']
+
+## Foreground color of the statusbar in caret mode.
+## Type: QssColor
+c.colors.statusbar.caret.fg = nord['nord5']
+
+## Background color of the statusbar in caret mode with a selection.
+## Type: QssColor
+c.colors.statusbar.caret.selection.bg = nord['nord15']
+
+## Foreground color of the statusbar in caret mode with a selection.
+## Type: QssColor
+c.colors.statusbar.caret.selection.fg = nord['nord5']
+
+## Background color of the statusbar in command mode.
+## Type: QssColor
+c.colors.statusbar.command.bg = nord['nord2']
+
+## Foreground color of the statusbar in command mode.
+## Type: QssColor
+c.colors.statusbar.command.fg = nord['nord5']
+
+## Background color of the statusbar in private browsing + command mode.
+## Type: QssColor
+c.colors.statusbar.command.private.bg = nord['nord2']
+
+## Foreground color of the statusbar in private browsing + command mode.
+## Type: QssColor
+c.colors.statusbar.command.private.fg = nord['nord5']
+
+## Background color of the statusbar in insert mode.
+## Type: QssColor
+c.colors.statusbar.insert.bg = nord['nord14']
+
+## Foreground color of the statusbar in insert mode.
+## Type: QssColor
+c.colors.statusbar.insert.fg = nord['nord1']
+
+## Background color of the statusbar.
+## Type: QssColor
+c.colors.statusbar.normal.bg = nord['nord0']
+
+## Foreground color of the statusbar.
+## Type: QssColor
+c.colors.statusbar.normal.fg = nord['nord5']
+
+## Background color of the statusbar in passthrough mode.
+## Type: QssColor
+c.colors.statusbar.passthrough.bg = nord['nord10']
+
+## Foreground color of the statusbar in passthrough mode.
+## Type: QssColor
+c.colors.statusbar.passthrough.fg = nord['nord5']
+
+## Background color of the statusbar in private browsing mode.
+## Type: QssColor
+c.colors.statusbar.private.bg = nord['nord3']
+
+## Foreground color of the statusbar in private browsing mode.
+## Type: QssColor
+c.colors.statusbar.private.fg = nord['nord5']
+
+## Background color of the progress bar.
+## Type: QssColor
+c.colors.statusbar.progress.bg = nord['nord5']
+
+## Foreground color of the URL in the statusbar on error.
+## Type: QssColor
+c.colors.statusbar.url.error.fg = nord['nord11']
+
+## Default foreground color of the URL in the statusbar.
+## Type: QssColor
+c.colors.statusbar.url.fg = nord['nord5']
+
+## Foreground color of the URL in the statusbar for hovered links.
+## Type: QssColor
+c.colors.statusbar.url.hover.fg = nord['nord8']
+
+## Foreground color of the URL in the statusbar on successful load
+## (http).
+## Type: QssColor
+c.colors.statusbar.url.success.http.fg = nord['nord5']
+
+## Foreground color of the URL in the statusbar on successful load
+## (https).
+## Type: QssColor
+c.colors.statusbar.url.success.https.fg = nord['nord14']
+
+## Foreground color of the URL in the statusbar when there's a warning.
+## Type: QssColor
+c.colors.statusbar.url.warn.fg = nord['nord12']
+
+## Background color of the tab bar.
+## Type: QtColor
+c.colors.tabs.bar.bg = nord['nord3']
+
+## Background color of unselected even tabs.
+## Type: QtColor
+c.colors.tabs.even.bg = nord['nord3']
+
+## Foreground color of unselected even tabs.
+## Type: QtColor
+c.colors.tabs.even.fg = nord['nord5']
+
+## Color for the tab indicator on errors.
+## Type: QtColor
+c.colors.tabs.indicator.error = nord['nord11']
+
+## Color gradient start for the tab indicator.
+## Type: QtColor
+# c.colors.tabs.indicator.start = nord['violet']
+
+## Color gradient end for the tab indicator.
+## Type: QtColor
+# c.colors.tabs.indicator.stop = nord['orange']
+
+## Color gradient interpolation system for the tab indicator.
+## Type: ColorSystem
+## Valid values:
+## - rgb: Interpolate in the RGB color system.
+## - hsv: Interpolate in the HSV color system.
+## - hsl: Interpolate in the HSL color system.
+## - none: Don't show a gradient.
+c.colors.tabs.indicator.system = 'none'
+
+## Background color of unselected odd tabs.
+## Type: QtColor
+c.colors.tabs.odd.bg = nord['nord3']
+
+## Foreground color of unselected odd tabs.
+## Type: QtColor
+c.colors.tabs.odd.fg = nord['nord5']
+
+# ## Background color of selected even tabs.
+# ## Type: QtColor
+c.colors.tabs.selected.even.bg = nord['nord0']
+
+# ## Foreground color of selected even tabs.
+# ## Type: QtColor
+c.colors.tabs.selected.even.fg = nord['nord5']
+
+# ## Background color of selected odd tabs.
+# ## Type: QtColor
+c.colors.tabs.selected.odd.bg = nord['nord0']
+
+# ## Foreground color of selected odd tabs.
+# ## Type: QtColor
+c.colors.tabs.selected.odd.fg = nord['nord5']
+
+## Background color for webpages if unset (or empty to use the theme's
+## color)
+## Type: QtColor
+# c.colors.webpage.bg = 'white'
diff --git a/qutebrowser/qutebrowser_view_in_mpv.bash b/qutebrowser/qutebrowser_view_in_mpv.bash
@@ -0,0 +1,143 @@
+#!/usr/bin/env bash
+#
+# Behavior:
+# Userscript for qutebrowser which views the current web page in mpv using
+# sensible mpv-flags. While viewing the page in MPV, all <video>, <embed>,
+# and <object> tags in the original page are temporarily removed. Clicking on
+# such a removed video restores the respective video.
+#
+# In order to use this script, just start it using `spawn --userscript` from
+# qutebrowser. I recommend using an alias, e.g. put this in the
+# [alias]-section of qutebrowser.conf:
+#
+# mpv = spawn --userscript /path/to/view_in_mpv
+#
+# Background:
+# Most of my machines are too slow to play youtube videos using html5, but
+# they work fine in mpv (and mpv has further advantages like video scaling,
+# etc). Of course, I don't want the video to be played (or even to be
+# downloaded) twice — in MPV and in qwebkit. So I often close the tab after
+# opening it in mpv. However, I actually want to keep the rest of the page
+# (comments and video suggestions), i.e. only the videos should disappear
+# when mpv is started. And that's precisely what the present script does.
+#
+# Thorsten Wißmann, 2015 (thorsten` on freenode)
+# Any feedback is welcome!
+
+set -e
+
+if [ -z "$QUTE_FIFO" ] ; then
+ cat 1>&2 <<EOF
+Error: $0 can not be run as a standalone script.
+
+It is a qutebrowser userscript. In order to use it, call it using
+'spawn --userscript' as described in qute://help/userscripts.html
+EOF
+ exit 1
+fi
+
+msg() {
+ local cmd="$1"
+ shift
+ local msg="$*"
+ if [ -z "$QUTE_FIFO" ] ; then
+ echo "$cmd: $msg" >&2
+ else
+ echo "message-$cmd '${msg//\'/\\\'}'" >> "$QUTE_FIFO"
+ fi
+}
+
+MPV_COMMAND=${MPV_COMMAND:-mpv}
+# Warning: spaces in single flags are not supported
+MPV_FLAGS=${MPV_FLAGS:- --force-window --no-terminal --keep-open=yes --ytdl --no-osc}
+IFS=" " read -r -a video_command <<< "$MPV_COMMAND $MPV_FLAGS"
+
+js() {
+cat <<EOF
+
+ function descendantOfTagName(child, ancestorTagName) {
+ // tells whether child has some (proper) ancestor
+ // with the tag name ancestorTagName
+ while (child.parentNode != null) {
+ child = child.parentNode;
+ if (typeof child.tagName === 'undefined') break;
+ if (child.tagName.toUpperCase() == ancestorTagName.toUpperCase()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ var App = {};
+
+ var all_videos = [];
+ all_videos.push.apply(all_videos, document.getElementsByTagName("video"));
+ all_videos.push.apply(all_videos, document.getElementsByTagName("object"));
+ all_videos.push.apply(all_videos, document.getElementsByTagName("embed"));
+ App.backup_videos = Array();
+ App.all_replacements = Array();
+ for (i = 0; i < all_videos.length; i++) {
+ var video = all_videos[i];
+ if (descendantOfTagName(video, "object")) {
+ // skip tags that are contained in an object, because we hide
+ // the object anyway.
+ continue;
+ }
+ var replacement = document.createElement("div");
+ replacement.innerHTML = "
+ <p style=\\"margin-bottom: 0.5em\\">
+ Opening page with:
+ <span style=\\"font-family: monospace;\\">${video_command[*]}</span>
+ </p>
+ <p>
+ In order to restore this particular video
+ <a style=\\"font-weight: bold;
+ color: white;
+ background: transparent;
+ \\"
+ onClick=\\"restore_video(this, " + i + ");\\"
+ href=\\"javascript: restore_video(this, " + i + ")\\"
+ >click here</a>.
+ </p>
+ ";
+ replacement.style.position = "relative";
+ replacement.style.zIndex = "100003000000";
+ replacement.style.fontSize = "1rem";
+ replacement.style.textAlign = "center";
+ replacement.style.verticalAlign = "middle";
+ replacement.style.height = "100%";
+ replacement.style.background = "#101010";
+ replacement.style.color = "white";
+ replacement.style.border = "4px dashed #545454";
+ replacement.style.padding = "2em";
+ replacement.style.margin = "auto";
+ App.all_replacements[i] = replacement;
+ App.backup_videos[i] = video;
+ video.parentNode.replaceChild(replacement, video);
+ }
+
+ function restore_video(obj, index) {
+ obj = App.all_replacements[index];
+ video = App.backup_videos[index];
+ console.log(video);
+ obj.parentNode.replaceChild(video, obj);
+ }
+
+ /** force repainting the video, thanks to:
+ * http://martinwolf.org/2014/06/10/force-repaint-of-an-element-with-javascript/
+ */
+ var siteHeader = document.getElementById('header');
+ siteHeader.style.display='none';
+ siteHeader.offsetHeight; // no need to store this anywhere, the reference is enough
+ siteHeader.style.display='block';
+
+EOF
+}
+
+printjs() {
+ js | sed 's,//.*$,,' | tr '\n' ' '
+}
+echo "jseval -q $(printjs)" >> "$QUTE_FIFO"
+
+msg info "Opening $QUTE_URL with mpv"
+"${video_command[@]}" "$@" "$QUTE_URL"