diff --git a/.config/qutebrowser/config.py b/.config/qutebrowser/config.py index ef84971..242a829 100644 --- a/.config/qutebrowser/config.py +++ b/.config/qutebrowser/config.py @@ -387,10 +387,16 @@ c.fonts.web.size.minimum = 15 # Bindings for normal mode config.bind(';#', 'hint code userscript code_select.py') -config.bind(';g', 'hint links userscript qute-gemini') +config.bind(';D', 'spawn --userscript dark_mode.user ;; greasemonkey-reload') config.bind(';G', 'hint links userscript qute-gemini-tab') config.bind(';b', 'hint links userscript getbib') -config.bind(';m', 'hint links spawn mpv --gpu-context=wayland --hwdec=auto {hint-url}') +config.bind(';g', 'hint links userscript qute-gemini') +config.bind(';m', 'hint links spawn nohup mpv --gpu-context=wayland --hwdec=auto {hint-url}') +config.bind(',m', 'spawn nohup mpv --gpu-context=wayland --hwdec=auto {url}') +config.bind(';lh', 'spawn --userscript localhost') +config.bind(';ls', 'spawn --userscript speak') +config.bind('wa', 'open https://web.archive.org/web/{url}') +config.bind(';wa', 'hint links fill :open -t https://web.archive.org/web/{hint-url}') config.bind('', 'zoom-in') config.bind('', 'zoom-out') # save web pages in MHTML diff --git a/home.nix b/home.nix index 8b8ba24..2245b54 100644 --- a/home.nix +++ b/home.nix @@ -191,6 +191,112 @@ ''; executable = true; }; + ".config/qutebrowser/userscripts/localhost" = { + executable = true; + text = '' + #!/usr/bin/env bash + + export BEMENU_OPTS="--tb '#6272a4' --tf '#f8f8f2' --fb '#282a36' --ff '#f8f8f2' + --nb '#282a36' --nf '#6272a4' --hb '#44475a' --hf '#50fa7b' --sb '#44475a' --sf + '#50fa7b' --scb '#282a36' --scf '#ff79c6' -p 'localhost: ▶' --fork -l 5 + --fn 'FiraCode Retina 17'" + + if [[ $1 -eq 'list' ]] && [[ -z $QUTE_COUNT ]]; + then + PORTS="$(ss -nltp | tail -n +2 | awk '{print $4}' | awk -F: '{print $2}')" + QUTE_COUNT=$(echo "$PORTS" | bemenu -n ) + fi + + # echo open -t localhost:''${QUTE_COUNT:-8080} > $QUTE_FIFO + [ -n "$QUTE_COUNT" ] && echo open -t localhost:"''${QUTE_COUNT}" > $QUTE_FIFO + ''; + }; + ".config/qutebrowser/userscripts/speak" = { + executable = true; + text = '' + #!/bin/bash + export IFS=$'\n' + pkill -f qute_speak || { + ~/.local/bin/gtts-cli "$QUTE_SELECTED_TEXT" | mpv --no-video --speed=1.26 - + # ~/.local/bin/gtts-cli "$QUTE_SELECTED_TEXT" > /tmp/qute_speak.mp3 + # mpv /tmp/qute_speak.mp3 + } + ''; + }; + ".config/qutebrowser/userscripts/dark_mode.user" = { + executable = true; + text = '' + #!/bin/zsh + + # on a new system cp DR.js DarkReader.user.js + darkreader_file="$HOME/.config/qutebrowser/greasemonkey/DarkReader.user.js" + enabled="^//DarkReader.disable();" + darkreader_enabled="$(grep -q -e "$enabled" $darkreader_file; echo $?)" + # echo $darkreader_enabled + + if [[ "$(echo $darkreader_enabled)" == "1" ]]; then + # enable DarkReader by commenting out the line that disables it. + sed -i --follow-symlink 's/DarkReader.disable()/\/\/DarkReader.disable()/' "$darkreader_file" + else + # disable DarkReader + sed -i --follow-symlink 's/\/\/DarkReader.disable()/DarkReader.disable()/' "$darkreader_file" + fi + ''; + }; + ".config/qutebrowser/greasemonkey/DR.js" = { + text = '' + // ==UserScript== + // @name Dark Reader (Unofficial) + // @icon https://darkreader.org/images/darkreader-icon-256x256.png + // @namespace DarkReader + // @description Inverts the brightness of pages to reduce eye strain + // @version 4.9.52 + // @author https://github.com/darkreader/darkreader#contributors + // @homepageURL https://darkreader.org/ | https://github.com/darkreader/darkreader + // @run-at document-end + // @grant none + // @exclude https://git.dotya.ml* + // @exclude https://dotya.ml* + // @exclude https://status.dotya.ml* + // @exclude https://searxng.dotya.ml* + // @exclude https://grafana.dotya.ml* + // @exclude https://github.com* + // @exclude https://dnswatch.com* + // @exclude https://docs.immudb.io* + // @exclude https://woodpecker-ci.org* + // @exclude https://duckduckgo.com* + // @exclude https://www.redit.com* + // @exclude https://codeberg.org* + // @include http* + // @require https://cdn.jsdelivr.net/npm/darkreader/darkreader.min.js + // @noframes + // ==/UserScript== + + DarkReader.enable({ + brightness: 105, + contrast: 105, + sepia: 0 + }); + DarkReader.disable(); + ''; + }; + ".config/qutebrowser/userscripts/code_select.py" = { + executable = true; + source = .local/share/qutebrowser/userscripts/code_select.py; + }; + ".config/qutebrowser/userscripts/getbib" = { + executable = true; + source = .local/share/qutebrowser/userscripts/getbib; + }; + ".config/qutebrowser/userscripts/qute-gemini" = { + executable = true; + source = .local/share/qutebrowser/userscripts/qute-gemini; + }; + ".config/qutebrowser/userscripts/qute-gemini-tab" = { + executable = true; + source = .local/share/qutebrowser/userscripts/qute-gemini; + }; + ".local/bin/workqb" = { text = '' #!/bin/zsh