dotfiles/.config/qutebrowser/config.py
Marty Oehme 170415bc40 Improve qutebrowser configuration file
Added
* keybindings to hide/display tabbar
* leader-key binding mimicking vim
* darkmode/lightmode unified stylesheets in solarized theme
* lazy tab restoration on loading sessions
* tab closing/restoring with x/X
2019-05-22 19:58:30 +02:00

85 lines
2.6 KiB
Python

from qutebrowser.config.configfiles import ConfigAPI # noqa: F401
from qutebrowser.config.config import ConfigContainer # noqa: F401
import os
# Autogenerated config.py
# Documentation:
# qute://help/configuring.html
# qute://help/settings.html
# Uncomment this to still load settings configured via autoconfig.yml
config.load_autoconfig()
# Enable JavaScript.
# Type: Bool
config.set('content.javascript.enabled', True, 'file://*')
# Enable JavaScript.
# Type: Bool
config.set('content.javascript.enabled', True, 'chrome://*/*')
# Enable JavaScript.
# Type: Bool
config.set('content.javascript.enabled', True, 'qute://*/*')
c.editor.command = ["alacritty", "-e", "nvim", "-f", "{file}"]
# LOOK
# ----
# Tab-Bar
# have tab bar on the right, not on the top
c.tabs.position = "right"
c.tabs.width = "15%"
# give the browser nice nord theme colors
config.source('nordtheme.py')
# Status bar
# should be visible to prevent 'jumping' bug, see https://github.com/qutebrowser/qutebrowser/issues/2236
# TODO think about implementing a simple toggle for the statusbar, like for the tabs
c.statusbar.hide = False
# CSS
DARK_STYLESHEET = config.configdir / \
"stylesheets/solarized-dark.css"
LIGHT_STYLESHEET = config.configdir / \
"stylesheets/solarized-light.css"
if DARK_STYLESHEET.exists() and LIGHT_STYLESHEET.exists():
css = [str(DARK_STYLESHEET), str(LIGHT_STYLESHEET)]
# 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('tt', 'config-cycle -t tabs.show always switching')
# bind mpv to play the current page/links, using a single instance which queues the next link passed
config.bind('M', 'spawn umpv {url}')
config.bind('m', 'hint links spawn umpv {hint-url}')
# Let me close tabs more easily, and 'unclose' them with the same key
config.bind('x', 'tab-close', mode='normal')
config.bind('X', 'undo', mode='normal')
# 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"
# set stylesheets for the browser to use
# leader - ss to remove all applied stylesheets
config.bind(leader + 'ss', 'set content.user_stylesheets ""')
# leader - sd for dark mode solarized
config.bind(leader + 'sd', 'set content.user_stylesheets ' + str(css[0]) )
# leader - sl for light mode solarized
config.bind(leader + 'sl', 'set content.user_stylesheets ' + str(css[1]) )