From: Maximilian Friedersdorff Date: Tue, 4 Jun 2019 13:45:18 +0000 (+0100) Subject: Manage qutebrowser configuration X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=b8622a7a74ab5d434d3654bbd4d3b71696b1bde7;p=max%2Fsaltfiles.git Manage qutebrowser configuration --- diff --git a/states/dotfiles.sls b/states/dotfiles.sls index 6613eb2..09b6ce8 100644 --- a/states/dotfiles.sls +++ b/states/dotfiles.sls @@ -5,3 +5,4 @@ include: - vim - mail - termite + - qutebrowser diff --git a/states/qutebrowser/files/config.py b/states/qutebrowser/files/config.py new file mode 100644 index 0000000..23a7752 --- /dev/null +++ b/states/qutebrowser/files/config.py @@ -0,0 +1,32 @@ +config.load_autoconfig() + +c.auto_save.session = True +c.content.cookies.accept = 'no-3rdparty' +c.content.cookies.store = False +c.content.javascript.enabled = False +c.content.images = True +c.editor.command = ['urxvt', '-e', 'vim', '{file}'] +c.tabs.position = 'left' +c.url.auto_search = 'dns' +c.url.searchengines = {'DEFAULT': 'https://duckduckgo.com/?q={}'} +c.messages.timeout = 5000 +c.tabs.background = True + +config.bind(',ej', 'spawn --userscript noscript_enable') +config.bind(',dj', 'spawn --userscript noscript_disable') + +config.bind(',zl', 'spawn --userscript qute-pass --dmenu-invocation dmenu') +config.bind(',zul', 'spawn --userscript qute-pass --dmenu-invocation dmenu --username-only') +config.bind(',zpl', 'spawn --userscript qute-pass --dmenu-invocation dmenu --password-only') +config.bind(',zol', 'spawn --userscript qute-pass --dmenu-invocation dmenu --otp-only') + +# Allow JS and cookies on own domain +config.set('content.javascript.enabled', True, '*.friedersdorff.com') + +# Fingerprinting protection +c.content.headers.accept_language = 'en-US,en;q=0.5' +c.content.headers.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' +c.content.headers.custom = {'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'} + +# wayland +c.window.hide_decoration = True diff --git a/states/qutebrowser/files/noscript_disable b/states/qutebrowser/files/noscript_disable new file mode 100755 index 0000000..77eb76f --- /dev/null +++ b/states/qutebrowser/files/noscript_disable @@ -0,0 +1,5 @@ +#!/bin/sh + +SANITIZED_URL="$(echo $QUTE_URL | sed 's/[^/]*\/\/\([^@]*@\)\?\([^/]*\).*/\2\/\*/')" + +echo "set -u $SANITIZED_URL content.javascript.enabled false" >> "$QUTE_FIFO" diff --git a/states/qutebrowser/files/noscript_enable b/states/qutebrowser/files/noscript_enable new file mode 100755 index 0000000..25334ad --- /dev/null +++ b/states/qutebrowser/files/noscript_enable @@ -0,0 +1,5 @@ +#!/bin/sh + +SANITIZED_URL="$(echo $QUTE_URL | sed 's/[^/]*\/\/\([^@]*@\)\?\([^/]*\).*/\2\/\*/')" + +echo "set -u $SANITIZED_URL content.javascript.enabled true" >> "$QUTE_FIFO" diff --git a/states/qutebrowser/gentoo.sls b/states/qutebrowser/gentoo.sls new file mode 100644 index 0000000..ab946c7 --- /dev/null +++ b/states/qutebrowser/gentoo.sls @@ -0,0 +1,18 @@ +qutebrowser useflags: + file.managed: + - name: /etc/portage/package.use/qutebrowser-salt + - contents: + - dev-qt/qtmultimedia widgets + - dev-python/PyQt5 multimedia + - dev-python/pyyaml libyaml + - www-client/qutebrowser scripts + - dev-python/PyQtWebEngine widgets + - user: root + - group: root + - mode: 644 + +install qutebrowser: + pkg.installed: + - name: www-client/qutebrowser + - require: + - file: qutebrowser useflags diff --git a/states/qutebrowser/init.sls b/states/qutebrowser/init.sls new file mode 100644 index 0000000..13349ed --- /dev/null +++ b/states/qutebrowser/init.sls @@ -0,0 +1,62 @@ +include: + - qutebrowser.{{ grains['os'] | lower}} + - local.bin + + +userscripts dir: + file.directory: + - name: {{ grains['homedir'] }}/.local/share/qutebrowser/userscripts + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750 + - makedirs: True + - require: + - pkg: install qutebrowser + +symlink qute-pass: + file.symlink: + - name: {{ grains['homedir'] }}/.local/share/qutebrowser/userscripts/qute-pass + - target: /usr/share/qutebrowser/userscripts/qute-pass + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750 + - require: + - file: userscripts dir + +noscript_enable file: + file.managed: + - name: {{ grains['homedir'] }}/.local/share/qutebrowser/userscripts/noscript_enable + - source: salt://qutebrowser/files/noscript_enable + - user: {{ grains['user'] }} + - groups: {{ grains['user'] }} + - mode: 750 + - require: + - file: userscripts dir + +noscript_disable file: + file.managed: + - name: {{ grains['homedir'] }}/.local/share/qutebrowser/userscripts/noscript_disable + - source: salt://qutebrowser/files/noscript_disable + - user: {{ grains['user'] }} + - groups: {{ grains['user'] }} + - mode: 750 + - require: + - file: userscripts dir + +qutebrowser wrapper: + file.managed: + - name: {{ grains['homedir'] }}/.local/bin/qutebrowser + - contents: + - #!/bin/sh + - /usr/bin/qutebrowser --qt-flag disable-reading-from-canvas $@ + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750 + +qutebrowser config: + file.managed: + - name: {{ grains['homedir'] }}/.config/qutebrowser/config.py + - source: salt://qutebrowser/files/config.py + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 640