config.py (4552B)
1 from PyQt5.QtCore import QUrl 2 from qutebrowser.api import interceptor 3 from qutebrowser.browser import commands 4 import subprocess 5 6 # import <str> can mean import ./<str>.py apparently. 7 # Great, transparent, design. 8 import search 9 import stylesheets 10 11 # Qutebrowser requires me to tell it this or else it 12 # gives an annoying message each time it opens. 13 config.load_autoconfig(False) 14 15 # Save tabs + urls 16 c.auto_save.session = True 17 18 # Didn't ask. 19 c.changelog_after_upgrade = 'never' 20 21 # Don't annoy me. 22 c.new_instance_open_target = 'tab-bg-silent' 23 24 # Selected tabs 25 c.colors.tabs.selected.even.bg = '#1b364b' 26 c.colors.tabs.selected.odd.bg = '#1b364b' 27 c.colors.tabs.selected.even.fg = 'white' 28 c.colors.tabs.selected.odd.fg = 'white' 29 30 # Unselected tabs 31 c.colors.tabs.even.bg = '#050a10' 32 c.colors.tabs.odd.bg = '#050a10' 33 c.colors.tabs.even.fg = 'white' 34 c.colors.tabs.odd.fg = 'white' 35 36 # Tabbed muscle memory 37 config.bind('<Alt-q>', 'tab-close') 38 config.bind('<Alt-h>', 'tab-prev') 39 config.bind('<Alt-l>', 'tab-next') 40 config.bind('<Alt-Shift-h>', 'tab-prev') 41 config.bind('<Alt-Shift-l>', 'tab-next') 42 43 # Darkmode 44 c.colors.webpage.bg = '#050a10' 45 c.colors.webpage.darkmode.algorithm = 'lightness-cielab' 46 c.colors.webpage.darkmode.enabled = True 47 c.colors.webpage.darkmode.policy.images = 'never' 48 c.colors.webpage.darkmode.policy.page = 'always' 49 c.colors.webpage.preferred_color_scheme = 'dark' 50 51 # Configuration 52 ## cd to qutebrowser dir before editing to get quick access to other files 53 c.editor.command = ['rc', '-c', 'cd `$nl{dirname \'{file}\'}; st -e vim `$nl{basename \'{file}\'}'] 54 config.bind('R', 'config-source') 55 config.bind('e', 'config-edit') 56 57 # I need to plumb 58 config.bind('d', 'hint all spawn plumb {hint-url}') 59 config.bind('D', 'hint all spawn rc -c \'net/download -d {hint-url}\'') 60 config.bind('v', 'hint all spawn rc -c \'nohup mpv --pause {hint-url} >/dev/null >[2]/dev/null &\'') 61 62 # Warp the mouse as seen by qtwebengine 63 config.bind('a', 'hint all hover') 64 65 # Alphabet soup 66 config.bind('A', 'spawn --userscript randomagent') 67 c.content.headers.user_agent = '.' 68 69 # Stylesheets 70 c.content.user_stylesheets = stylesheets.list 71 72 # Home/default page 73 c.url.default_page = 'about:blank' 74 config.bind('~', 'open file:///home/hayden/.config/qutebrowser/home.html') 75 76 # Hint characters. 77 # Same as the default, but with f placed last. It seems that qutebrowser will 78 # construct multichar hints by going right to left to select the first char. 79 # Since f is the default hint binding I think this will make hints quicker to 80 # type as my finger should already be on f when it is generating hints such as 81 # 'fa', 'fb', 'fc'... 82 c.hints.chars = 'asdlghjkf' 83 84 # Search (search.py) 85 c.url.open_base_url = True 86 c.url.searchengines = search.list 87 88 # Security 89 ## Uh-oh gmail might break with this option! Oh no! 90 c.content.cookies.accept = 'no-3rdparty' 91 ## DNT does nothing but provide a more unique fingerprint 92 c.content.headers.do_not_track = None 93 ## I know, I know, but I don't care. 94 c.downloads.prevent_mixed_content = False 95 96 # Redirects 97 def domainredir(info: interceptor.Request): 98 host = info.request_url.host() 99 target = QUrl(info.request_url) 100 101 # Fuck python. Why can't I split these out on to multiple lines and indent 102 # them? Why can't you give me a switch statement? I would love for 103 # string-capable switch statements to exist in more languages. 104 if (host == 'twitter.com' or host == 'www.twitter.com' or host == 'mobile.twitter.com'): 105 target.setHost('nitter.net'); 106 elif (host == 'reddit.com' or host == 'www.reddit.com' or host == 'old.reddit.com'): 107 target.setHost('teddit.net'); 108 elif (host == 'instagram.com' or host == 'www.instagram.com'): 109 target.setHost('bibliogram.art'); 110 elif (host == 'en.m.wikipedia.org'): 111 target.setHost('en.wikipedia.org'); 112 elif (host == 'npr.org' or host == 'www.npr.org'): 113 target.setHost('text.npr.org'); 114 else: 115 return 116 117 try: 118 info.redirect(target) 119 except interceptor.interceptors.RedirectException: 120 pass 121 interceptor.register(domainredir) 122 123 # Clipboard (use primary for everything) 124 config.unbind('Pp') 125 config.unbind('PP') 126 config.unbind('pp') 127 config.unbind('pP') 128 config.unbind('yD') 129 config.unbind('yM') 130 config.unbind('yP') 131 config.unbind('yT') 132 config.unbind('yY') 133 config.bind('P', 'open -t -- {primary}') 134 config.bind('p', 'open -- {primary}') 135 config.bind('yd', 'yank domain -s') 136 config.bind('ym', 'yank inline [{title}]({url}) -s') 137 config.bind('yp', 'yank pretty-url -s') 138 config.bind('yt', 'yank title -s') 139 config.bind('yy', 'yank -s')