~yerinalexey/dotfiles

ref: 33b9bc6d6ebecad159ba7812ffb913a503fca8de dotfiles/qutebrowser/config.py -rw-r--r-- 6.3 KiB
33b9bc6dAlexey Yerin river: updates to layout 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Search engines & homepage
import os

searx_instance = "https://searx.info"

homepage = os.path.join(config.configdir, "homepage", "index.html")

c.url.start_pages = homepage
c.url.default_page = homepage
c.url.searchengines = {
    "DEFAULT": f"{searx_instance}/?q={{}}",
    "aw": "https://wiki.archlinux.org/index.php?search={}",
    "mdn": "https://developer.mozilla.org/en-US/search?q={}",
    "gd": "https://godocs.io/?q={}",
    "ruststd": "https://doc.rust-lang.org/stable/std/?search={}",
    "docsrs": "https://docs.rs/releases/search?query={}",
    "godocs": "https://github.com/search?q={}",
}

# Ignore autoconfig
config.load_autoconfig(False)

# Set editor
c.editor.command = [os.getenv("TERMINAL"), os.getenv("EDITOR"), "{file}"]

# Enable smooth scrolling so pages are not so painful to scroll through
c.scrolling.smooth = True

# Do not forward keys to the page
# This makes using browser a mess when some keys are forwarded and some
# are not
c.input.forward_unbound_keys = "none"

# Use xdg-open for opening downloads
# Opening chromium for PDFs is not a good idea (but QB does that)
c.downloads.open_dispatcher = "xdg-open"

# Key bindings
## Reader mode
config.bind("gR", f"spawn --userscript {config.configdir}/userscripts/readability")

## Pin/unpin tab
config.bind("gp", "tab-pin")

## Push the current tab to the end
config.bind("gM", "tab-move -1")

## Edit current URL
config.bind("e", "set-cmd-text :open {url:pretty}")
config.bind("E", "set-cmd-text :open -t {url:pretty}")

## Inserting text
config.bind("i", "mode-enter insert")
config.bind("I", "hint inputs")

## Copy/paste
config.bind("ys", "yank selection")
config.bind("yf", "hint links yank")
config.bind("p", "open -- {clipboard}")
config.bind("P", "open -t -- {clipboard}")

## Images
config.bind(",if", "hint images userscript open-image")
config.bind(",id", "hint images download")
config.bind(",iy", "hint images yank")

## Userscripts
config.bind(f",d", "spawn --userscript dictionary")

## Command prompt
config.bind("<Ctrl-j>", "completion-item-focus next", mode="command")
config.bind("<Ctrl-k>", "completion-item-focus prev", mode="command")

# Allow JS and notifications when needed
def load_list(name):
    with open(config.datadir / name) as f:
        return f.read().split()

allow_js = [
    # Localhosts
    "http://127.0.0.1:*/*",
    "http://localhost:*/*",

    # Rust stuff
    "https://rust-lang.github.io/rust-clippy/*",
    "https://doc.rust-lang.org/*",
    "https://crates.io/*",
    "https://docs.rs/*",

    # Other documentation
    "https://stedolan.github.io/jq/*",
    "https://*.archlinux.org/*",

    # Interactive apps
    "https://www.nerdfonts.com/cheat-sheet/*",
    "https://app.simplelogin.io/*",
    "https://wordsmith.social/*",
    "https://fosstodon.org/*",
    "https://tour.golang.org/*",
    "https://app.element.io/*",
    "https://matrix.slashdev.space/*",
    "https://ihateregex.io/*",

    # Peertube instances
    "https://spacepub.space/*",
    "https://tilvids.com/*",
    "https://tube.privacytools.io/*",
    "https://peertube.social/*",

    # A bit broken without JS
    "https://slashdev.space/*",
    "https://github.com/*",
    "https://codeberg.org/*",
    "https://gitlab.com/*",

    # JS-only by design
    # No one wants to leak metadata about who you were invited to talk
    # to
    "https://matrix.to/*",

    # Adds some fancy features
    f"{searx_instance}/*",
    "https://*.sr.ht/*",
    "https://golang.org/*",
    "https://godocs.io/*"
] + load_list("allow-js")

allow_notifications = [
    "https://app.element.io",
    "https://fosstodon.org",
    "https://matrix.slashdev.space",
] + load_list("allow-notify")

for url in allow_js:
    config.set("content.javascript.enabled", True, url)

config.set("content.notifications.presenter", "libnotify")
for url in allow_notifications:
    config.set("content.notifications.enabled", True, url)

# Privacy
## Minimize fingerprint
c.content.headers.user_agent = "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0"
c.content.headers.accept_language = "en-US,en;q=0.5"
c.content.headers.custom = {
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}

## No third-party cookies
c.content.cookies.accept = "no-3rdparty"

## Disable JS and other stuff
c.content.javascript.can_open_tabs_automatically = False
#c.content.canvas_reading = False
c.content.webgl = False

config.set("content.javascript.enabled", False)

# Spellcheck
c.spellcheck.languages = ["en-US"]

# Dark theme go brr
c.colors.webpage.preferred_color_scheme = "dark"

# Colors, UI
secondary_color = "#282c34"
selected_color = "#3671cf"
match_color = "#fd8351"
even_color = "#383c44"
odd_color = "#454a53"
fg_color = "#fefefe"

## Fix scrollbar
c.scrolling.bar = "always"

## Completion menu
c.colors.completion.item.selected.border.bottom = selected_color
c.colors.completion.item.selected.border.top = selected_color
c.colors.completion.item.selected.bg = selected_color
c.colors.completion.item.selected.match.fg = match_color
c.colors.completion.item.selected.fg = fg_color

c.colors.completion.category.bg = secondary_color
c.colors.completion.match.fg = match_color
c.colors.completion.even.bg = even_color
c.colors.completion.odd.bg = odd_color

## Status bar
c.colors.statusbar.command.bg = secondary_color
c.colors.statusbar.normal.bg = secondary_color
c.colors.statusbar.passthrough.bg = "#9c832b"
c.colors.statusbar.insert.bg = "#468751"
c.colors.statusbar.caret.bg = "#5183d2"

c.colors.statusbar.url.success.https.fg = \
    c.colors.statusbar.url.success.http.fg = "#999999"
c.colors.statusbar.url.hover.fg = "#fff"

## Tabs
c.tabs.favicons.show = "pinned"
c.tabs.title.format = "{audio}{current_title}"
c.tabs.tooltips = False

c.colors.tabs.bar.bg = secondary_color
c.colors.tabs.selected.even.bg = selected_color
c.colors.tabs.selected.odd.bg  = selected_color
c.colors.tabs.even.bg = even_color
c.colors.tabs.odd.bg = odd_color

c.colors.tabs.pinned.selected.even.bg = selected_color
c.colors.tabs.pinned.selected.odd.bg  = selected_color
c.colors.tabs.pinned.even.bg = "#228928"
c.colors.tabs.pinned.odd.bg = "#196a1e"

## Link hints
c.colors.hints.match.fg = match_color
c.colors.hints.bg = secondary_color
c.colors.hints.fg = fg_color
c.hints.border = f"1px solid #3f3f3f"

## Prompts
c.prompt.radius = 5

c.colors.prompts.bg = secondary_color
c.colors.prompts.fg = fg_color
c.colors.prompts.selected.bg = "#505050"