From 5c0a7339a502412f2b74be96c70f1f9a51c97277 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 9 Feb 2021 22:07:07 -0500 Subject: [PATCH] Polish qutebrowser theme, integration, & config --- config/qutebrowser/config.py | 88 +++++-------------- .../greasemonkey/let-there-be-light.user.js | 15 +++- .../per-domain-stylesheets.user.js | 2 +- modules/desktop/browsers/qutebrowser.nix | 2 +- .../alucard/config/qutebrowser/theme.py | 71 ++++++++------- 5 files changed, 72 insertions(+), 106 deletions(-) diff --git a/config/qutebrowser/config.py b/config/qutebrowser/config.py index 7c83b217..66a40621 100644 --- a/config/qutebrowser/config.py +++ b/config/qutebrowser/config.py @@ -10,15 +10,13 @@ c.content.javascript.enabled = True c.content.local_storage = True c.content.plugins = True -# c.confirm_quit = ['never'] -c.editor.command = ['emacsclient', '-c', '-a', ' ', '+{line}:{column}', '{}'] +c.editor.encoding = 'utf-8' ## Security & privacy -c.content.mute = True # mute tabs by default c.content.autoplay = False # don't autoplay videos ## Adblocking -# Use (superior) Brave adblock if available; fall back to host blocking +# Use (superior) Brave adblock if available, or fall back to host blocking c.content.blocking.method = "auto" c.content.blocking.hosts.lists = [ 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts', @@ -30,77 +28,23 @@ c.content.blocking.hosts.lists = [ ] # c.content.blocking.whitelist = [] +## Options c.downloads.position = 'bottom' c.downloads.location.directory = os.path.expanduser("~/dl") c.downloads.location.prompt = False - -c.editor.encoding = 'utf-8' - - -## Options -# c.history_gap_interval = 30 -# c.ignore_case = 'smart' -# c.input.forward_unbound_keys = 'auto' -# c.input.insert_mode.auto_leave = True +c.input.insert_mode.auto_leave = True c.input.insert_mode.auto_load = False -# c.input.insert_mode.plugins = False -# c.input.links_included_in_focus_chain = True -# c.input.partial_timeout = 5000 -# c.input.rocker_gestures = False -# c.input.spatial_navigation = False -# c.keyhint.blacklist = [] -# c.keyhint.delay = 500 -# c.messages.timeout = 2000 -# c.messages.unfocused = False +c.input.links_included_in_focus_chain = False c.new_instance_open_target = 'tab-silent' -# c.new_instance_open_target_window = 'last-focused' c.prompt.filebrowser = False c.prompt.radius = 0 -# c.qt.args = [] -# c.qt.force_platform = None -# c.qt.force_software_rendering = False -c.scrolling.smooth = False -# c.session_default_name = None c.spellcheck.languages = ['en-US'] -c.session.lazy_restore = False - -# c.statusbar.padding = {'top': 4, 'bottom': 4, 'left': 4, 'right': 4} -# c.statusbar.hide = False -# c.statusbar.position = 'bottom' - -# c.tabs.background = True -# c.tabs.padding = {'top': 4, 'bottom': 4, 'left': 0, 'right': 3} -# c.tabs.indicator.padding = {'top': 0, 'bottom': 0, 'left': 0, 'right': 5} -# c.tabs.mousewheel_switching = False -# c.tabs.close_mouse_button = 'middle' -# c.tabs.favicons.scale = 1.0 -# c.tabs.favicons.show = True -# c.tabs.last_close = 'ignore' -# c.tabs.new_position.related = 'next' -# c.tabs.new_position.unrelated = 'last' -# c.tabs.position = 'top' -# c.tabs.select_on_remove = 'next' +c.session.lazy_restore = True c.tabs.show = 'multiple' -c.tabs.title.format = '{current_title} - {host}' +c.tabs.title.format = '{audio}{current_title} - {host}' c.tabs.title.format_pinned = '' -c.tabs.indicator.width = 1 -# c.tabs.wrap = True - -# c.url.auto_search = 'naive' -# c.url.default_page = 'https://start.duckduckgo.com/' -# c.url.incdec_segments = ['path', 'query'] -# c.url.searchengines = {'DEFAULT': 'https://duckduckgo.com/?q={}'} -# c.url.start_pages = ['https://start.duckduckgo.com'] -# c.url.yank_ignored_parameters = ['ref', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'] - -# c.window.hide_wayland_decoration = False c.window.title_format = '{current_title} - {host} - qutebrowser' -# c.zoom.default = '100%' -# c.zoom.levels = ['25%', '33%', '50%', '67%', '75%', '90%', '100%', '110%', '125%', '150%', '175%', '200%', '250%', '300%', '400%', '500%'] -# c.zoom.mouse_divider = 512 -# c.zoom.text_only = False - # ## Keybindings @@ -114,12 +58,24 @@ for mode in ['caret', 'command', 'hint', 'insert', 'passthrough', 'prompt', 'reg config.bind('zz', 'close') config.bind('tm', 'tab-mute') config.bind('wi', 'devtools bottom') +config.bind(';;', 'hint inputs --first') # easier to reach than ;t +config.bind(';e', 'hint inputs --first ;; fake-key ;; :spawn nohup bspc rule -a "Emacs:*" -o state=floating sticky=on && emacsclient --eval "(emacs-everywhere)"') # ;v already bound to 'spawn mpv {url}' config.bind(';V', 'hint links spawn mpv {hint-url}') +# Use external editor +c.editor.command = ['emacsclient', '-c', '-F', '((name . "qutebrowser-editor"))', '+{line}:{column}', '{}'] +# Though we set it, I use the more specialzied emacs-everywhere instead +config.bind('', 'edit-text', mode='insert') +config.bind('', 'hint inputs --first ;; edit-text', mode='normal') +config.bind('', 'fake-key ', mode='insert') + # Bitwarden integration -config.bind(";p", ':spawn -u qute-bwmenu') -config.bind(";P", 'spawn bwmenu') +config.bind(";pp", 'spawn -u qute-bwmenu') +config.bind(";pu", 'spawn -u qute-bwmenu --field username') +config.bind(";ps", 'spawn -u qute-bwmenu --field password') +config.bind(";po", 'spawn -u qute-bwmenu --field otp') +config.bind(";pl", 'spawn -u qute-bwmenu --last') ## Ex-commands @@ -343,7 +299,7 @@ config.bind('', 'rl-forward-word', mode='command') # config.bind('', 'hint all tab-bg', mode='hint') # config.bind('', 'hint links', mode='hint') # config.bind('', 'hint --rapid links tab-bg', mode='hint') -# config.bind('', 'leave-mode', mode='hint') +# config.bind('', 'mode-leave', mode='hint') # config.bind('', 'follow-hint', mode='hint') ## Bindings for insert mode diff --git a/config/qutebrowser/greasemonkey/let-there-be-light.user.js b/config/qutebrowser/greasemonkey/let-there-be-light.user.js index 09de60e8..4f306856 100644 --- a/config/qutebrowser/greasemonkey/let-there-be-light.user.js +++ b/config/qutebrowser/greasemonkey/let-there-be-light.user.js @@ -8,5 +8,16 @@ // Needed to counterbalance my colors.webpage.bg hack to prevent the blinding // flash of white between page loads. -var sheet = window.document.styleSheets[0]; -sheet.insertRule('body { background-color: white; }', sheet.cssRules.length); +(function () { + 'use strict'; + + function _bg(element) { + return window.getComputedStyle(element).backgroundColor; + } + + if (_bg(document.documentElement) === "rgba(0, 0, 0, 0)" && + _bg(document.body) === "rgba(0, 0, 0, 0)") { + var sheet = window.document.styleSheets[0]; + sheet.insertRule('body { background-color: white; }', sheet.cssRules.length); + } +})(); diff --git a/config/qutebrowser/greasemonkey/per-domain-stylesheets.user.js b/config/qutebrowser/greasemonkey/per-domain-stylesheets.user.js index b3fc69b7..8f2f54c6 100644 --- a/config/qutebrowser/greasemonkey/per-domain-stylesheets.user.js +++ b/config/qutebrowser/greasemonkey/per-domain-stylesheets.user.js @@ -8,7 +8,7 @@ // @author Henrik Lissner // ==/UserScript== -(function IIFE() { +(function () { 'use strict'; document.addEventListener('readystatechange', function onReadyStateChange() { diff --git a/modules/desktop/browsers/qutebrowser.nix b/modules/desktop/browsers/qutebrowser.nix index 36d4dda2..00cdf355 100644 --- a/modules/desktop/browsers/qutebrowser.nix +++ b/modules/desktop/browsers/qutebrowser.nix @@ -25,7 +25,7 @@ in { desktopName = "Qutebrowser (Private)"; genericName = "Open a private Qutebrowser window"; icon = "qutebrowser"; - exec = ''${pkg}/bin/qutebrowser ":open -p"''; + exec = ''${pkg}/bin/qutebrowser -T -s content.private_browsing true''; categories = "Network"; }) # For Brave adblock in qutebrowser, which is significantly better than the diff --git a/modules/themes/alucard/config/qutebrowser/theme.py b/modules/themes/alucard/config/qutebrowser/theme.py index 1334fb1c..e454bd83 100644 --- a/modules/themes/alucard/config/qutebrowser/theme.py +++ b/modules/themes/alucard/config/qutebrowser/theme.py @@ -1,8 +1,7 @@ ## Colors palette = { 'background': '#282a36', - 'background-alt': '#282a36', - 'background-attention': '#181920', + 'background-alt': '#1E2029', 'border': '#282a36', 'current-line': '#44475a', 'selection': '#44475a', @@ -20,8 +19,8 @@ palette = { } spacing = { - 'vertical': 5, - 'horizontal': 5 + 'vertical': 6, + 'horizontal': 4 } padding = { @@ -47,15 +46,15 @@ c.fonts.default_family = "JetBrainsMono" c.fonts.default_size = "10pt" # Background color of the completion widget category headers. -c.colors.completion.category.bg = palette['background'] +c.colors.completion.category.bg = palette['background-alt'] # Bottom border color of the completion widget category headers. -c.colors.completion.category.border.bottom = palette['border'] +c.colors.completion.category.border.bottom = palette['background-alt'] # Top border color of the completion widget category headers. c.colors.completion.category.border.top = palette['border'] # Foreground color of completion widget category headers. c.colors.completion.category.fg = palette['foreground'] # Background color of the completion widget for even rows. -c.colors.completion.even.bg = palette['background'] +c.colors.completion.even.bg = palette['background-alt'] # Background color of the completion widget for odd rows. c.colors.completion.odd.bg = palette['background-alt'] # Text color of the completion widget. @@ -75,13 +74,13 @@ c.colors.completion.scrollbar.bg = palette['background'] # Color of the scrollbar handle in completion view. c.colors.completion.scrollbar.fg = palette['foreground'] # Background color for the download bar. -c.colors.downloads.bar.bg = palette['background'] +c.colors.downloads.bar.bg = palette['background-alt'] # Background color for downloads with errors. -c.colors.downloads.error.bg = palette['background'] +c.colors.downloads.error.bg = palette['background-alt'] # Foreground color for downloads with errors. c.colors.downloads.error.fg = palette['red'] # Color gradient stop for download backgrounds. -c.colors.downloads.stop.bg = palette['background'] +c.colors.downloads.stop.bg = palette['background-alt'] ## Color gradient interpolation system for download backgrounds. ## Type: ColorSystem @@ -94,69 +93,69 @@ c.colors.downloads.system.bg = 'none' ## Background color for hints. Note that you can use a `rgba(...)` value # for transparency. -c.colors.hints.bg = palette['background'] +c.colors.hints.bg = palette['background-alt'] # Font color for hints. c.colors.hints.fg = palette['purple'] # Hints -c.hints.border = '1px solid ' + palette['background-alt'] +c.hints.border = '1px solid ' + palette['background'] # Font color for the matched part of hints. c.colors.hints.match.fg = palette['foreground-alt'] # Background color of the keyhint widget. -c.colors.keyhint.bg = palette['background'] +c.colors.keyhint.bg = palette['background-alt'] # Text color for the keyhint widget. c.colors.keyhint.fg = palette['purple'] # Highlight color for keys to complete the current keychain. c.colors.keyhint.suffix.fg = palette['selection'] # Background color of an error message. -c.colors.messages.error.bg = palette['background'] +c.colors.messages.error.bg = palette['background-alt'] # Border color of an error message. -c.colors.messages.error.border = palette['background-alt'] +c.colors.messages.error.border = palette['background'] # Foreground color of an error message. c.colors.messages.error.fg = palette['red'] # Background color of an info message. -c.colors.messages.info.bg = palette['background'] +c.colors.messages.info.bg = palette['background-alt'] # Border color of an info message. -c.colors.messages.info.border = palette['background-alt'] +c.colors.messages.info.border = palette['background'] # Foreground color an info message. c.colors.messages.info.fg = palette['comment'] # Background color of a warning message. -c.colors.messages.warning.bg = palette['background'] +c.colors.messages.warning.bg = palette['background-alt'] # Border color of a warning message. -c.colors.messages.warning.border = palette['background-alt'] +c.colors.messages.warning.border = palette['border'] # Foreground color a warning message. c.colors.messages.warning.fg = palette['red'] # Background color for prompts. -c.colors.prompts.bg = palette['background'] +c.colors.prompts.bg = palette['background-alt'] # Border used around UI elements in prompts. -c.colors.prompts.border = '1px solid ' + palette['background-alt'] +c.colors.prompts.border = '1px solid ' + palette['background'] # Foreground color for prompts. c.colors.prompts.fg = palette['cyan'] # Background color for the selected item in filename prompts. c.colors.prompts.selected.bg = palette['selection'] # Background color of the statusbar in caret mode. -c.colors.statusbar.caret.bg = palette['background'] +c.colors.statusbar.caret.bg = palette['background-alt'] # Foreground color of the statusbar in caret mode. c.colors.statusbar.caret.fg = palette['orange'] # Background color of the statusbar in caret mode with a selection. -c.colors.statusbar.caret.selection.bg = palette['background'] +c.colors.statusbar.caret.selection.bg = palette['background-alt'] # Foreground color of the statusbar in caret mode with a selection. c.colors.statusbar.caret.selection.fg = palette['orange'] # Background color of the statusbar in command mode. -c.colors.statusbar.command.bg = palette['background'] +c.colors.statusbar.command.bg = palette['background-alt'] # Foreground color of the statusbar in command mode. c.colors.statusbar.command.fg = palette['pink'] # Background color of the statusbar in private browsing + command mode. -c.colors.statusbar.command.private.bg = palette['background'] +c.colors.statusbar.command.private.bg = palette['background-alt'] # Foreground color of the statusbar in private browsing + command mode. -c.colors.statusbar.command.private.fg = palette['foreground-alt'] +c.colors.statusbar.command.private.fg = palette['foreground'] # Background color of the statusbar in insert mode. -c.colors.statusbar.insert.bg = palette['background-attention'] +c.colors.statusbar.insert.bg = palette['background-alt'] # Foreground color of the statusbar in insert mode. -c.colors.statusbar.insert.fg = palette['foreground-attention'] +c.colors.statusbar.insert.fg = palette['pink'] # Background color of the statusbar. -c.colors.statusbar.normal.bg = palette['background'] +c.colors.statusbar.normal.bg = palette['background-alt'] # Foreground color of the statusbar. -c.colors.statusbar.normal.fg = palette['foreground'] +c.colors.statusbar.normal.fg = palette['foreground-alt'] # Background color of the statusbar in passthrough mode. c.colors.statusbar.passthrough.bg = palette['background'] # Foreground color of the statusbar in passthrough mode. @@ -166,7 +165,7 @@ c.colors.statusbar.private.bg = palette['background-alt'] # Foreground color of the statusbar in private browsing mode. c.colors.statusbar.private.fg = palette['foreground-alt'] # Background color of the progress bar. -c.colors.statusbar.progress.bg = palette['background'] +c.colors.statusbar.progress.bg = palette['background-alt'] # Foreground color of the URL in the statusbar on error. c.colors.statusbar.url.error.fg = palette['red'] # Default foreground color of the URL in the statusbar. @@ -182,11 +181,11 @@ c.colors.statusbar.url.warn.fg = palette['yellow'] # Status bar padding c.statusbar.padding = padding # Background color of the tab bar. -c.colors.tabs.bar.bg = palette['selection'] +c.colors.tabs.bar.bg = palette['background-alt'] # Background color of unselected even tabs. -c.colors.tabs.even.bg = palette['selection'] +c.colors.tabs.even.bg = palette['background-alt'] # Foreground color of unselected even tabs. -c.colors.tabs.even.fg = palette['foreground'] +c.colors.tabs.even.fg = palette['comment'] # Color for the tab indicator on errors. c.colors.tabs.indicator.error = palette['red'] # Color gradient start for the tab indicator. @@ -204,9 +203,9 @@ c.colors.tabs.indicator.stop = palette['green'] c.colors.tabs.indicator.system = 'none' # Background color of unselected odd tabs. -c.colors.tabs.odd.bg = palette['selection'] +c.colors.tabs.odd.bg = palette['background-alt'] # Foreground color of unselected odd tabs. -c.colors.tabs.odd.fg = palette['foreground'] +c.colors.tabs.odd.fg = palette['comment'] # Background color of selected even tabs. c.colors.tabs.selected.even.bg = palette['background'] # Foreground color of selected even tabs.