diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2024-05-14 18:53:03 +0200 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2024-05-14 18:53:03 +0200 |
commit | 612dbb6993c8a548744f29a4d15d6b31325357c8 (patch) | |
tree | 0d61cee0ea74ac811268d0ffc00d3d55f7174112 | |
parent | 23e2bfd987c430bb41bc7860c46c2f572e9e2db4 (diff) | |
download | dots-trunk.tar.gz |
33 files changed, 530 insertions, 170 deletions
diff --git a/.bin/cmus-consistency b/.bin/cmus-consistency new file mode 100755 index 0000000..dae667b --- /dev/null +++ b/.bin/cmus-consistency @@ -0,0 +1,23 @@ +#!/bin/sh + +set -xe + +music_urls_file="${HOME}/.config/music/urls" +music_path="${HOME}/music" +music_album_list_file="$(mktemp)" + +find "${music_path}" -maxdepth 1 -type d -not -path "${music_path}" -not -name ".*" \ + | sort \ + | xargs -I {} basename {} \ + > "${music_album_list_file}" + +grep -v "^http" "${music_urls_file}" \ + | grep -v "^#" \ + | tr -s "\n" \ + | sort \ + | uniq \ + | diff - "${music_album_list_file}" \ + | grep -e "^>" -e "^<" \ + | sort -V + +rm "${music_album_list_file}" diff --git a/.bin/cmus-find-unused b/.bin/cmus-find-unused new file mode 100755 index 0000000..2fd5f1c --- /dev/null +++ b/.bin/cmus-find-unused @@ -0,0 +1,20 @@ +#!/bin/sh +# Find tracks in no playlist + +set -xe + +cmus_path="${HOME}/.config/cmus" +music_path="${HOME}/music" +cmus_playlist_files="$(mktemp)" + +cat "${cmus_path}/playlists/"* \ + | sort \ + | uniq \ + > "${cmus_playlist_files}" + +find "${music_path}" -type f -not -name ".*" \ + | sort \ + | uniq \ + | comm -23 - "${cmus_playlist_files}" + +rm "${cmus_playlist_files}" diff --git a/.bin/cmus-find-unused-dir b/.bin/cmus-find-unused-dir new file mode 100755 index 0000000..189bb12 --- /dev/null +++ b/.bin/cmus-find-unused-dir @@ -0,0 +1,24 @@ +#!/bin/sh + +set -xe + +cmus_path="${HOME}/.config/cmus" +music_path="${HOME}/music" +cmus_playlist_files="$(mktemp)" + +cat "${cmus_path}/playlists/"* \ + | xargs -d "\n" -I {} dirname {} \ + | xargs -I {} basename {} \ + | sort \ + | uniq \ + > "${cmus_playlist_files}" + +cmus-find-unused \ + | xargs -d "\n" -I {} dirname {} \ + | grep -v -e "^${music_path}$" -e "\." \ + | xargs -I {} basename {} \ + | sort \ + | uniq \ + | comm -23 - "${cmus_playlist_files}" + +rm "${cmus_playlist_files}" diff --git a/.bin/config.ini b/.bin/config.ini new file mode 100755 index 0000000..9f4986e --- /dev/null +++ b/.bin/config.ini @@ -0,0 +1,8 @@ +[AAAA-aaa] + +a = "a" + +[bbb] +bb +cc +dd diff --git a/.bin/dot-sync b/.bin/dot-sync index f12f878..f41b936 100755 --- a/.bin/dot-sync +++ b/.bin/dot-sync @@ -4,11 +4,11 @@ set -xe export GIT_SSH_COMMAND="ssh -o ConnectTimeout=1 -o ConnectionAttempts=1" -yadm stash -yadm pull --rebase -yadm stash pop +yadm stash || true +yadm pull --rebase || true +yadm stash pop || true -yadm add -u +yadm add -u || true yadm add \ "${HOME}/.bin" \ "${HOME}/.config/cmus/playlists" \ @@ -28,7 +28,8 @@ yadm add \ "${HOME}/.config/yadm" \ "${HOME}/.config/waybar" \ "${HOME}/.config/zk" \ - "${HOME}/.public-keys" + "${HOME}/.public-keys" \ + || true yadm push diff --git a/.bin/dslr-webcam b/.bin/dslr-webcam new file mode 100755 index 0000000..a1c9084 --- /dev/null +++ b/.bin/dslr-webcam @@ -0,0 +1,27 @@ +#!/bin/sh + +set -xe + +VIDEO_INDEX="${1:-1}" + +# gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -f v4l2 "/dev/video${VIDEO_INDEX}" + +gphoto2 --stdout --capture-movie | + ffmpeg \ + -threads:v 2 \ + -threads:a 8 \ + -filter_threads 2 \ + -thread_queue_size 512 \ + -hwaccel opencl \ + -fflags nobuffer \ + -flags low_delay \ + -strict experimental \ + -probesize 819200 \ + -analyzeduration 0 \ + -i - \ + -vcodec rawvideo \ + -preset ultrafast \ + -tune zerolatency \ + -pix_fmt yuv420p \ + -f v4l2 "/dev/video${VIDEO_INDEX}" \ + -framerate 30 diff --git a/.bin/dwm-start b/.bin/dwm-start index b42252a..e2dcc00 100755 --- a/.bin/dwm-start +++ b/.bin/dwm-start @@ -22,7 +22,7 @@ while true; do # x11 configuration x11-config - . ~/.bin/x11-screen + ag-autorandr # dwm dwm 2> ~/.dwm.log @@ -1,63 +1,37 @@ #!/usr/bin/python3 +import logging import os import sys -import yt_dlp -from dataclasses import dataclass - - -def _match_filter(info: dict, *, incomplete) -> str | None: - _duration = info.get("duration") - _duration_min = 60 - - if _duration and int(_duration) < _duration_min: - return "Duration too short: < _duration_min" - return None +import yt_dlp # type: ignore[import] +from dataclasses import dataclass -@dataclass(frozen=True) -class Collection: - """A music collection.""" - - title: str - links: frozenset[str] - - def __eq__(self, other) -> bool: - if isinstance(other, Collection): - return self.title == other.title - raise NotImplementedError - +logging.basicConfig() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) -def parse_raw_to_collections(raw_data: list[str]) -> frozenset[Collection]: - collections: set[Collection] = set() - _collection_data: list[str] = [] - for index, line in enumerate(raw_data): - if line.startswith("#"): - continue - elif line == "" or index + 1 == len(raw_data): - if len(_collection_data) == 0: - continue +def get_ytdlp_options(output_dir: str) -> dict: + """yt_dlp download and convertion options.""" - collections.add( - Collection(_collection_data[0], frozenset(_collection_data[1:])) - ) - _collection_data.clear() - else: - _collection_data.append(line) + def match_filter(info: dict, *, incomplete) -> str | None: + duration = info.get("duration") + duration_min = 60 - return frozenset(collections) + if duration is not None and int(duration) < duration_min: + return "Duration too short: < _duration_min" + return None -def get_ytdlp_options(output_dir: str) -> dict: return { "format": "bestaudio/best", - "match_filter": _match_filter, + "match_filter": match_filter, "postprocessors": [ { "key": "FFmpegExtractAudio", - #"preferredcodec": "m4a", + # "preferredcodec": "m4a", }, { "key": "FFmpegMetadata", @@ -71,31 +45,128 @@ def get_ytdlp_options(output_dir: str) -> dict: "outtmpl": f"{output_dir}/%(title)s.%(ext)s", "restrictfilenames": True, "ignoreerrors": True, + "writethumbnail": True, } -def download_collection(collection: Collection, parent_dir: str) -> None: - output_dir = os.path.join(parent_dir, collection.title) +def parse_raw_lines(lines: list[str]) -> list[list[str]]: + """Parse collections of name + link(s) + + (Usually stored in a text file). + """ + entries: list[list[str]] = list() + entry: list[str] = list() + + for index, line in enumerate(lines): + + # entries are separated by an empty line. + if line == "": + entries.append(entry) + entry = list() + continue + + entry.append(line) - if os.path.isdir(output_dir): - return + # handle the last entry when reaching the end of the file. + if index + 1 == len(lines): + entries.append(entry) + entry = list() - os.makedirs(output_dir, exist_ok=True) + return entries - with yt_dlp.YoutubeDL(get_ytdlp_options(output_dir)) as downloader: - downloader.download(collection.links) + +@dataclass(frozen=True) +class Link: + """A music link.""" + + url: str + is_enabled: bool + + +@dataclass(frozen=True) +class Collection: + """A music collection.""" + + name: str + links: tuple[Link, ...] + is_enabled: bool + + def __eq__(self, other) -> bool: + if isinstance(other, Collection): + return self.name == other.name + + raise NotImplementedError + + +def sanitize_entry_informations( + entry: str, indicator: str = "#" +) -> tuple[str, bool]: + + is_comment = entry.startswith(indicator) + + if is_comment: + entry = entry.split(indicator, 1)[1].lstrip() + + return entry, not is_comment + + +def create_link(entry: str) -> Link: + url, is_enabled = sanitize_entry_informations(entry) + return Link(url=url, is_enabled=is_enabled) + + +def create_collection(entry: list[str]) -> Collection: + """Create a collection from a raw entry.""" + name, is_enabled = sanitize_entry_informations(entry[0]) + links = [create_link(_link) for _link in entry[1:]] + + return Collection( + name=name, + links=tuple(links), + is_enabled=is_enabled + ) + + +def get_collection_dir(collection: Collection, parent_dir: str) -> str: + return os.path.join(parent_dir, collection.name) + + +def download_collection(collection: Collection, directory: str) -> None: + """Download a music collection to the local filesystem.""" + + # create directory and download/convert with opinionated settings. + os.makedirs(directory, exist_ok=True) + + with yt_dlp.YoutubeDL(get_ytdlp_options(directory)) as downloader: + for link in collection.links: + if not link.is_enabled: + logger.info(f"Skipping {collection.name}, {link}") + continue + + logger.info(f"Downloading {collection.name}, {link}") + downloader.download(link.url) def main() -> int: - # input handling + """Main entrypoint.""" + + # argument handling if len(sys.argv) != 2: return 1 with open(sys.argv[1], "r") as file: filedata = file.read().splitlines() - for collection in parse_raw_to_collections(filedata): - download_collection(collection, os.getcwd()) + for entry in parse_raw_lines(filedata): + collection = create_collection(entry) + output_dir = get_collection_dir(collection, os.getcwd()) + + if os.path.isdir(output_dir) or not collection.is_enabled: + logger.info(f"Skipping {collection.name}") + continue + + logger.info(f"Handling {collection.name}") + download_collection(collection, output_dir) return 0 diff --git a/.bin/python-chad b/.bin/python-chad new file mode 100755 index 0000000..3fc230e --- /dev/null +++ b/.bin/python-chad @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e + +venv_path=$(poetry env info -p || true) + +if [ "${?}" -eq 0 ]; then + export PATH="${venv_path}/bin:${PATH}" +fi + +set -x + +isort "${1:-.}" +black "${1:-.}" +flake8 "${1:-.}" diff --git a/.bin/ssh-personal b/.bin/ssh-personal new file mode 100755 index 0000000..e99764c --- /dev/null +++ b/.bin/ssh-personal @@ -0,0 +1,14 @@ +#!/bin/sh +# Used for work laptop. +# Add personal key and start the ssh-agent with it. + +set -xe + +ssh_personal_key="${HOME}/.ssh/id_personal" + +test -f "${ssh_personal_key}" + +eval "$(ssh-agent)" +ssh-add "${ssh_personal_key}" + +set +xe diff --git a/.bin/synchronize-pub-dots b/.bin/synchronize-pub-dots index 8c7a9c4..852a75c 100755 --- a/.bin/synchronize-pub-dots +++ b/.bin/synchronize-pub-dots @@ -2,8 +2,11 @@ set -e +# perform pre-flight checks command -v yadm git git rev-parse --is-inside-work-tree +[ "$(yadm rev-parse --show-toplevel)" != "$(git rev-parse --show-toplevel)" ] + allowed_patterns="-e ^.bin -e ^.config/alacritty/ @@ -39,8 +42,6 @@ allowed_patterns="-e ^.bin -e ^.zshrc " -[ "$(yadm rev-parse --show-toplevel)" != "$(git rev-parse --show-toplevel)" ] - # retrieve existing files upstream_files=$(cd "${HOME}" && yadm ls-files) local_files=$(find . -not -path "./.git*" -not -path ".") diff --git a/.bin/undock b/.bin/undock index c592fbf..4a9c14f 100755 --- a/.bin/undock +++ b/.bin/undock @@ -3,4 +3,5 @@ set -xe dock +xrandr --output eDP1 --mode 1920x1080 --primary xrandr -s 0 diff --git a/.bin/x11-config b/.bin/x11-config index 554f00c..d304547 100755 --- a/.bin/x11-config +++ b/.bin/x11-config @@ -7,7 +7,8 @@ synclient_options="TapButton1=1 \ TapButton2=3 \ TapButton3=2 \ PalmDetect=1 \ - TouchpadOff=0" + TouchpadOff=0 \ + VertScrollDelta=111" # synaptic if command -v syndaemon; then diff --git a/.bin/x11-screen b/.bin/x11-screen index 38ee006..82f8650 100755 --- a/.bin/x11-screen +++ b/.bin/x11-screen @@ -1,5 +1,7 @@ #!/bin/sh +set -x + __hidpi() { xrdb -merge ~/.Xresources.hidpi @@ -25,7 +27,7 @@ if [ "${hostname}" = "ws-xps01" ]; then __hidpi fi -if [ "${hostname}" = "work-01" ]; then +if [ "${hostname}" = "ws-work01" ]; then xrandr --output eDP1 --mode 1920x1080 xrandr --output DP3 --off xrandr --addmode DP3 1920x1080 diff --git a/.config/newsboat/config b/.config/newsboat/config index 52d7d61..0991034 100755 --- a/.config/newsboat/config +++ b/.config/newsboat/config @@ -1,6 +1,6 @@ max-items 100 reload-threads 100 -auto-reload yes +auto-reload no reload-time 30 text-width 80 ssl-verifyhost no diff --git a/.config/nvim/after/ftplugin/mail.lua b/.config/nvim/after/ftplugin/mail.lua index 7946291..a4bf6cc 100755 --- a/.config/nvim/after/ftplugin/mail.lua +++ b/.config/nvim/after/ftplugin/mail.lua @@ -1,4 +1,5 @@ o.colorcolumn = '72' bo.textwidth = 72 -bo.formatoptions = 'watqc' +-- bo.formatoptions = 'watqc' -- +bo.formatoptions = 'atcql' bo.smartindent = false diff --git a/.config/nvim/lua/plugins/indent-o-matic.lua b/.config/nvim/lua/plugins/indent-o-matic.lua index 517c3d8..d64f68c 100755 --- a/.config/nvim/lua/plugins/indent-o-matic.lua +++ b/.config/nvim/lua/plugins/indent-o-matic.lua @@ -15,5 +15,5 @@ require('indent-o-matic').setup { filetype_django = { max_lines = 4096 }, filetype_toml = { max_lines = 4096 }, filetype_yaml = { max_lines = 4096 }, - filetype_jsonnet = { max_lines = 4096 }, + filetype_proto = { max_lines = 4096 }, } diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index 9878222..1019549 100755 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -31,11 +31,12 @@ require('paq') { vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'git+https://github.com/python/mypy'}) vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'pylsp-mypy'}) vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'types-all'}) + vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'flake8'}) vim.fn.system({'python3', '-m', 'pipx', 'upgrade', '--include-injected', 'python-lsp-server'}) -- vim.fn.system({'python3', '-m', 'pip', 'install', '--force', 'debugpy'}) end }; - -- {'mickael-menu/zk-nvim'}; + {'mickael-menu/zk-nvim'}; { 'jose-elias-alvarez/null-ls.nvim', run = function() @@ -100,4 +101,4 @@ require('plugins.null-ls') require('plugins.telescope') require('plugins.treesitter') require('plugins.which-key') --- require('plugins.zk') +require('plugins.zk') diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 6d37467..14b001e 100755 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -30,7 +30,7 @@ vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', op vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts) -- require('lspconfig').ansiblels.setup{ on_attach = on_attach } -require('lspconfig').clangd.setup{ on_attach = on_attach } +require('lspconfig').clangd.setup{ on_attach = on_attach, filetypes = { "c", "cpp", "objc", "objcpp", "cuda" } } require('lspconfig').eslint.setup{ on_attach = on_attach } require('lspconfig').gopls.setup{ on_attach = on_attach } require('lspconfig').terraformls.setup{ on_attach = on_attach } @@ -62,16 +62,24 @@ require('lspconfig').pylsp.setup{ }, plugins = { flake8 = { + -- enabled = vim.fn.executable('flake8') == 1, enabled = true, ignore = {}, - maxLineLength = 160 + maxLineLength = 160, + cmd = 'flake8', }, rope_completion = { enabled = true, }, pyflakes = { - enabled = true + enabled = true, }, + pylsp_mypy = { + overrides = { + '--show-error-codes', + true + }, + } } } } diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/null-ls.lua index 3f84b26..d023193 100755 --- a/.config/nvim/lua/plugins/null-ls.lua +++ b/.config/nvim/lua/plugins/null-ls.lua @@ -2,6 +2,7 @@ require('null-ls').setup({ sources = { -- require('null-ls').builtins.diagnostics.ansiblelint, -- require('null-ls').builtins.diagnostics.markdownlint, + require('null-ls').builtins.diagnostics.buf, require('null-ls').builtins.diagnostics.eslint, require('null-ls').builtins.diagnostics.gitlint, require('null-ls').builtins.diagnostics.luacheck, diff --git a/.config/nvim/queries/python/highlights.scm b/.config/nvim/queries/python/highlights.scm index 2ea4847..a2179ec 100755 --- a/.config/nvim/queries/python/highlights.scm +++ b/.config/nvim/queries/python/highlights.scm @@ -1,5 +1,15 @@ ; extends -(block (expression_statement (string)) @docstring) +; function and class docstring detection +(block + (expression_statement + (string)) @docstring) +; shpinx detection in docstring +; (block +; (expression_statement +; (string +; (string_content))) @type) + +; type hint detection (type) @type diff --git a/.config/qutebrowser/config.py b/.config/qutebrowser/config.py index e24591b..4a44eef 100755 --- a/.config/qutebrowser/config.py +++ b/.config/qutebrowser/config.py @@ -1,4 +1,3 @@ - # ~/.config/qutebrowser/config.py # rgoncalves.se @@ -8,12 +7,10 @@ import os import re import socket -from PyQt5.QtCore import QUrl +from PyQt6.QtCore import QUrl from qutebrowser.api import cmdutils -from qutebrowser.browser.urlmarks import ( - AlreadyExistsError as UrlAlreadyExistsError -) +from qutebrowser.browser.urlmarks import AlreadyExistsError as UrlAlreadyExistsError from qutebrowser.browser.urlmarks import UrlMarkManager from qutebrowser.config.config import ConfigContainer from qutebrowser.config.configfiles import ConfigAPI @@ -27,13 +24,11 @@ c: ConfigContainer = c # noqa: F821 pylint: disable=E0602,C0103 logging.basicConfig(level=logging.DEBUG) -UrlMarkManager.save = ( - lambda manager: urlmarkmanager_save(manager, config.configdir) -) +UrlMarkManager.save = lambda manager: urlmarkmanager_save(manager, config.configdir) def is_musl_system() -> bool: - return bool(re.search('musl', os.popen('ldd /bin/ls').read())) + return bool(re.search("musl", os.popen("ldd /bin/ls").read())) def get_qt_arguments() -> list: @@ -41,24 +36,24 @@ def get_qt_arguments() -> list: Select best arguments for launching qutebrowser. Empty by default, it picks lag free options for musl systems. """ - filters = { - 'disable-seccomp-filter-sandbox': is_musl_system() - } + filters = {"disable-seccomp-filter-sandbox": is_musl_system()} - return list( - filter(lambda x: x, map(lambda x: x[1], list(filters.items()))) - ) + return list(filter(lambda x: x, map(lambda x: x[1], list(filters.items())))) try: + @cmdutils.register() def bookmark_save(url: QUrl): """Save the current page as a bookmark.""" - manager = objreg.get('bookmark-manager') + manager = objreg.get("bookmark-manager") tags = message.ask( title="Add bookmark:", mode=PromptMode.text, - url=url.toString(QUrl.RemovePassword | QUrl.FullyEncoded), + url=url.toString( + QUrl.UrlFormattingOption.RemovePassword + | QUrl.ComponentFormattingOption.FullyEncoded + ), text=( "Please enter bookmark tags for<br/><b>" f"{html.escape(url.toDisplayString())}</b>" @@ -72,90 +67,102 @@ try: manager.add(url, tags) except UrlAlreadyExistsError: message.warning("Bookmark already exists.") + except ValueError: pass config.load_autoconfig(False) -config.set('auto_save.session', True) -config.set('scrolling.smooth', False) -config.set('qt.highdpi', False) -config.set('qt.force_software_rendering', 'none') -config.set('qt.args', get_qt_arguments()) -config.set('messages.timeout', 2500) - -config.set('content.images', True, 'chrome-devtools://*') -config.set('content.images', True, 'devtools://*') -config.set('content.javascript.enabled', True, 'chrome-devtools://*') -config.set('content.javascript.enabled', True, 'devtools://*') -config.set('content.javascript.enabled', True, 'chrome://*/*') -config.set('content.javascript.enabled', True, 'qute://*/*') - -config.set('content.notifications.enabled', False) -config.set('content.notifications.enabled', True, '*://*.zoho.eu/*') -config.set('content.notifications.enabled', True, '*://*.viperdev.io/*') -config.set('content.notifications.enabled', True, '*://*.rgoncalves.se/*') -config.set('content.notifications.enabled', True, '*://app.slack.com/*') -config.set('content.notifications.enabled', True, '*://mail.google.com/*') - -config.set('content.register_protocol_handler', False) -config.set('content.geolocation', False) +config.set("auto_save.session", True) +config.set("scrolling.smooth", False) +config.set("scrolling.bar", "always") +config.set("qt.highdpi", False) +config.set("qt.force_software_rendering", "none") +config.set("qt.args", get_qt_arguments()) +config.set("messages.timeout", 2500) + +config.set("content.images", True, "chrome-devtools://*") +config.set("content.images", True, "devtools://*") +config.set("content.javascript.enabled", True, "chrome-devtools://*") +config.set("content.javascript.enabled", True, "devtools://*") +config.set("content.javascript.enabled", True, "chrome://*/*") +config.set("content.javascript.enabled", True, "qute://*/*") + +config.set("content.notifications.enabled", False) +config.set("content.notifications.enabled", True, "*://*.zoho.eu/*") +config.set("content.notifications.enabled", True, "*://*.viperdev.io/*") +config.set("content.notifications.enabled", True, "*://*.rgoncalves.se/*") +config.set("content.notifications.enabled", True, "*://app.slack.com/*") +config.set("content.notifications.enabled", True, "*://mail.google.com/*") + +config.set("content.register_protocol_handler", False) +config.set("content.geolocation", False) # config.set('content.media.audio_video_capture', True, '*://*.zoho.eu/*') # config.set('content.media.audio_capture', True, '*://*.zoho.eu/*') # config.set('content.media.video_capture', True, '*://*.zoho.eu/*') -config.set('content.media.audio_video_capture', True, 'https://meet.google.com/*') -config.set('content.media.audio_capture', True, 'https://meet.google.com/*') -config.set('content.media.video_capture', True, 'https://meet.google.com/*') - -config.set('completion.web_history.max_items', 0) -config.set('tabs.background', True) -config.set('tabs.indicator.width', 3) -config.set('tabs.indicator.padding', - {'bottom': 0, 'left': 1, 'right': 4, 'top': 0}) - -config.set('fonts.default_family', 'Terminus') -config.set('fonts.default_size', '12pt') - -config.set('colors.tabs.bar.bg', '#000000') -config.set('colors.tabs.even.bg', '#000000') -config.set('colors.tabs.even.fg', '#ffffff') -config.set('colors.tabs.odd.bg', '#000000') -config.set('colors.tabs.odd.fg', '#ffffff') -config.set('colors.tabs.indicator.system', 'none') -config.set('colors.tabs.selected.even.bg', '#ffffff') -config.set('colors.tabs.selected.even.fg', '#000000') -config.set('colors.tabs.selected.odd.bg', '#ffffff') -config.set('colors.tabs.selected.odd.fg', '#000000') -config.set('colors.tabs.pinned.selected.even.bg', '#ffffff') -config.set('colors.tabs.pinned.selected.odd.bg', '#ffffff') -config.set('colors.tabs.pinned.selected.even.fg', '#000000') -config.set('colors.tabs.pinned.selected.odd.fg', '#000000') -config.set('colors.tabs.indicator.error', '#ff0000') - -config.set('content.prefers_reduced_motion', True) -config.set('content.headers.referer', 'same-domain') -config.set('url.default_page', 'https://lite.duckduckgo.com/lite/') -config.set('url.start_pages', 'https://lite.duckduckgo.com/lite/') -config.set( - 'url.searchengines', {'DEFAULT': 'https://lite.duckduckgo.com/lite/?q={}'} -) - -config.set('downloads.location.directory', f'{os.environ["HOME"]}/downloads') -config.set('downloads.prevent_mixed_content', False) -config.set('content.autoplay', False) -config.set('content.cookies.accept', 'no-3rdparty') -config.set('content.javascript.alert', False) - -config.set('content.headers.do_not_track', False, '*://*.thetrainline.com/*') -config.set('content.blocking.enabled', False, '*://*.thetrainline.com/*') -config.set('content.cookies.accept', 'all', '*://*.thetrainline.com/*') +config.set("content.media.audio_video_capture", True, "https://meet.google.com/*") +config.set("content.media.audio_capture", True, "https://meet.google.com/*") +config.set("content.media.video_capture", True, "https://meet.google.com/*") + +config.set("completion.web_history.max_items", 0) +config.set("tabs.background", True) +config.set("tabs.indicator.width", 3) +config.set("tabs.indicator.padding", {"bottom": 0, "left": 1, "right": 4, "top": 0}) + +config.set("fonts.default_family", "Terminus") +config.set("fonts.default_size", "12pt") + +config.set("colors.tabs.bar.bg", "#000000") +config.set("colors.tabs.even.bg", "#000000") +config.set("colors.tabs.even.fg", "#ffffff") +config.set("colors.tabs.odd.bg", "#000000") +config.set("colors.tabs.odd.fg", "#ffffff") +config.set("colors.tabs.indicator.system", "none") +config.set("colors.tabs.selected.even.bg", "#ffffff") +config.set("colors.tabs.selected.even.fg", "#000000") +config.set("colors.tabs.selected.odd.bg", "#ffffff") +config.set("colors.tabs.selected.odd.fg", "#000000") +config.set("colors.tabs.pinned.selected.even.bg", "#ffffff") +config.set("colors.tabs.pinned.selected.odd.bg", "#ffffff") +config.set("colors.tabs.pinned.selected.even.fg", "#000000") +config.set("colors.tabs.pinned.selected.odd.fg", "#000000") +config.set("colors.tabs.indicator.error", "#ff0000") +config.set("tabs.padding", {"bottom": 0, "left": 4, "right": 4, "top": 0}) + +config.set("content.prefers_reduced_motion", True) +config.set("content.headers.referer", "same-domain") +# config.set('url.default_page', 'https://lite.duckduckgo.com/lite/') +# config.set('url.start_pages', 'https://lite.duckduckgo.com/lite/') +config.set("url.default_page", "qute://start") +config.set("url.start_pages", "qute://start") +config.set("url.searchengines", {"DEFAULT": "https://lite.duckduckgo.com/lite/?q={}"}) + +config.set("downloads.location.directory", f'{os.environ["HOME"]}/downloads') +config.set("downloads.prevent_mixed_content", False) +config.set("content.autoplay", False) +config.set("content.cookies.accept", "no-3rdparty") +config.set("content.javascript.alert", False) + +config.set("content.headers.do_not_track", False, "*://*.thetrainline.com/*") +config.set("content.blocking.enabled", False, "*://*.thetrainline.com/*") +config.set("content.cookies.accept", "all", "*://*.thetrainline.com/*") config.set( - 'editor.command', ["st", "nvim", "+normal {line}G{column0}l", "{file}"] + "content.blocking.adblock.lists", + [ + "https://easylist.to/easylist/easylist.txt", + "https://easylist.to/easylist/easyprivacy.txt", + "https://easylist-downloads.adblockplus.org/easylistdutch.txt", + "https://easylist-downloads.adblockplus.org/abp-filters-anti-cv.txt", + "https://www.i-dont-care-about-cookies.eu/abp/", + "https://secure.fanboy.co.nz/fanboy-cookiemonster.txt", + ], ) -config.bind(',m', 'spawn mpv --force-window=immediate {url}') -config.bind('M', 'bookmark-save {url}') +config.set("editor.command", ["st", "nvim", "+normal {line}G{column0}l", "{file}"]) + +config.bind(",m", "spawn mpv --force-window=immediate {url}") +config.bind("M", "bookmark-save {url}") -if socket.gethostname() == 'ws-work01': - config.set('fonts.default_size', '14pt') +if socket.gethostname() == "ws-work01": + config.set("fonts.default_size", "14pt") diff --git a/.config/qutebrowser/greasemonkey/1337x.js b/.config/qutebrowser/greasemonkey/1337x.js new file mode 100755 index 0000000..e892ba9 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/1337x.js @@ -0,0 +1,12 @@ +// ==UserScript== +// @name 1337x css +// @match *://1337x.to/* +// @grant none +// ==/UserScript== + +GM_addStyle(` + body > a:nth-last-child(2), + body > a:nth-last-child(1) { + z-index: -1 !important; + } +`) diff --git a/.config/qutebrowser/greasemonkey/amazon.js b/.config/qutebrowser/greasemonkey/amazon.js new file mode 100755 index 0000000..0edf4fd --- /dev/null +++ b/.config/qutebrowser/greasemonkey/amazon.js @@ -0,0 +1,62 @@ +// ==UserScript== +// @name Amazon CamelCamelCamel + Keepa Price Charts +// @version 1.0.8 +// @description Add a CamelCamelCamel and Keepa price charts to Amazon product pages. +// @author miki.it +// @namespace null +// @homepage https://github.com/mikispag/userscripts/ +// @include https://www.amazon.*/* +// @include https://smile.amazon.*/* +// @run-at document-end +// @downloadURL https://update.greasyfork.org/scripts/416590/Amazon%20CamelCamelCamel%20%2B%20Keepa%20Price%20Charts.user.js +// @updateURL https://update.greasyfork.org/scripts/416590/Amazon%20CamelCamelCamel%20%2B%20Keepa%20Price%20Charts.meta.js +// ==/UserScript== + +function getASIN() { + var asinElement = document.getElementById("ASIN") || document.evaluate("//@data-asin", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + if (!asinElement) { + throw new Error("Amazon CamelCamelCamel + Keepa Price Charts: unable to find ASIN!"); + } + return asinElement.value; +} + +window.addEventListener("load", function() { + var tld = document.domain.split(".").pop(); + var country = tld; + if (tld == "com") { + country = "us"; + } + + var asin = getASIN(); + if (!asin) { + throw new Error("Amazon CamelCamelCamel + Keepa Price Charts: unable to get ASIN!"); + } + + var parentElement = document.getElementById("unifiedPrice_feature_div") || document.getElementById("MediaMatrix"); + if (!parentElement) { + throw new Error("Amazon CamelCamelCamel + Keepa Price Charts: unable to get parent element!"); + } + + var camelChartContainer = document.createElement("div"); + var camelLink = document.createElement("a"); + camelLink.target = "_blank"; + camelLink.href = "https://" + country + ".camelcamelcamel.com/product/" + asin; + var camelChart = new Image(500, 400); + camelChart.src = "https://charts.camelcamelcamel.com/" + country + "/" + asin + "/amazon-new-used.png?force=1&zero=0&w=500&h=400&desired=false&legend=1&ilt=1&tp=all&fo=0"; + camelLink.appendChild(camelChart); + camelChartContainer.appendChild(camelLink); + + var keepaChartContainer = document.createElement("div"); + var keepaLink = document.createElement("a"); + keepaLink.target = "_blank"; + keepaLink.href = "https://keepa.com/#!product/8-" + asin; + var keepaChart = new Image(500, 200); + keepaChart.src = "https://graph.keepa.com/pricehistory.png?used=1&asin=" + asin + "&domain=" + tld; + keepaLink.appendChild(keepaChart); + keepaChartContainer.appendChild(keepaLink); + + var chartsContainer = document.createElement("div"); + chartsContainer.appendChild(camelChartContainer); + chartsContainer.appendChild(keepaChartContainer); + parentElement.appendChild(chartsContainer); +}, false); diff --git a/.config/qutebrowser/greasemonkey/boursorama.js b/.config/qutebrowser/greasemonkey/boursobank.js index 771bc38..6752ce3 100755 --- a/.config/qutebrowser/greasemonkey/boursorama.js +++ b/.config/qutebrowser/greasemonkey/boursobank.js @@ -1,6 +1,6 @@ // ==UserScript== // @name boursorama css -// @match *://*.boursorama.com/* +// @match *://*.boursobank.com/* // @grant none // ==/UserScript== diff --git a/.config/qutebrowser/greasemonkey/gitlab.js b/.config/qutebrowser/greasemonkey/gitlab.js index 5ebb8a3..987ca72 100755 --- a/.config/qutebrowser/greasemonkey/gitlab.js +++ b/.config/qutebrowser/greasemonkey/gitlab.js @@ -1,6 +1,6 @@ // ==UserScript== // @name gitlab -// @match *://*/* +// @match *://*gitlab*/* // @run-at document-end // @grant none // ==/UserScript== diff --git a/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js b/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js index d0735cb..7c0e240 100755 --- a/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js +++ b/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js @@ -5,4 +5,5 @@ // @run-at document-start // ==/UserScript== -top.location.hostname = "rimgo.pussthecat.org"; +// top.location.hostname = "rimgo.pussthecat.org"; +top.location.hostname = "rimgo.ducks.party"; diff --git a/.config/qutebrowser/greasemonkey/old-wiki.js b/.config/qutebrowser/greasemonkey/old-wiki.js new file mode 100755 index 0000000..d14775b --- /dev/null +++ b/.config/qutebrowser/greasemonkey/old-wiki.js @@ -0,0 +1,30 @@ +// ==UserScript== +// @name old wiki vector style +// @match *://*.wikipedia.org/* +// @match *://*.wiki.archlinux.org/* +// @grant none +// ==/UserScript== + +(function() { + const url = new URL(window.location.href); + + if(url.toString().indexOf('useskin') === -1){ + url.searchParams.set('useskin', 'vector'); + location.replace(url); + } + + const a = document.getElementsByTagName('a'); + + for (var i = 0; i < a.length; ++i){ + if(a[i].href.indexOf(window.location.host) === -1){ + continue; + } + + let href = new URL(a[i].href); + href.searchParams.set('useskin', 'vector'); + a[i].href = href; + } + + url.searchParams.delete('useskin'); + history.replaceState(null, document.title, url.href); +})(); diff --git a/.config/qutebrowser/greasemonkey/quora-to-quetre.js b/.config/qutebrowser/greasemonkey/quora-to-quetre.js new file mode 100755 index 0000000..8379119 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/quora-to-quetre.js @@ -0,0 +1,8 @@ +// ==UserScript== +// @name quora to quetre +// @match *://www.quora.com/* +// @grant none +// @run-at document-start +// ==/UserScript== + +top.location.hostname = "quetre.pussthecat.org"; diff --git a/.config/qutebrowser/greasemonkey/reddit-to-teddit.js b/.config/qutebrowser/greasemonkey/reddit-to-teddit.js index 8c1ee6b..788fecd 100755 --- a/.config/qutebrowser/greasemonkey/reddit-to-teddit.js +++ b/.config/qutebrowser/greasemonkey/reddit-to-teddit.js @@ -1,9 +1,11 @@ // ==UserScript== // @name reddit to teddit -// @match *://*.reddit.com/* // @match *://reddit.com/* +// @match *://www.reddit.com/* +// @exclude *://www.reddit.com/media* // @grant none // @run-at document-start // ==/UserScript== -top.location.hostname = "teddit.net"; +// top.location.hostname = "teddit.net"; +top.location.hostname = "old.reddit.com"; diff --git a/.config/qutebrowser/greasemonkey/unsplash.js b/.config/qutebrowser/greasemonkey/unsplash.js index 7d65781..17b117b 100755 --- a/.config/qutebrowser/greasemonkey/unsplash.js +++ b/.config/qutebrowser/greasemonkey/unsplash.js @@ -12,6 +12,7 @@ console.log("AAAAAAAA"); e.remove(); }); + })(); GM_addStyle(` @@ -21,3 +22,11 @@ GM_addStyle(` height: 0; } `) + +const text = 'Unsplash+'; +for (const container of document.querySelectorAll('figure')) { + if (container.textContent.includes(text)) { + container.remove(); + } + console.log(container); +} diff --git a/.config/qutebrowser/greasemonkey/yewtube.js b/.config/qutebrowser/greasemonkey/yewtube.js index c9f592b..f67db1b 100755 --- a/.config/qutebrowser/greasemonkey/yewtube.js +++ b/.config/qutebrowser/greasemonkey/yewtube.js @@ -6,4 +6,4 @@ // @run-at document-start // ==/UserScript== -document.cookie = "PREFS=%7B%22annotations%22%3Atrue%2C%22annotations_subscribed%22%3Afalse%2C%22autoplay%22%3Atrue%2C%22automatic_instance_redirect%22%3Atrue%2C%22captions%22%3A%5B%22%22%2C%22%22%2C%22%22%5D%2C%22comments%22%3A%5B%22youtube%22%2C%22reddit%22%5D%2C%22continue%22%3Afalse%2C%22continue_autoplay%22%3Atrue%2C%22dark_mode%22%3A%22light%22%2C%22latest_only%22%3Afalse%2C%22listen%22%3Afalse%2C%22local%22%3Atrue%2C%22watch_history%22%3Afalse%2C%22vr_mode%22%3Atrue%2C%22show_nick%22%3Afalse%2C%22locale%22%3A%22en-US%22%2C%22region%22%3A%22US%22%2C%22max_results%22%3A40%2C%22notifications_only%22%3Afalse%2C%22player_style%22%3A%22invidious%22%2C%22quality%22%3A%22dash%22%2C%22quality_dash%22%3A%221080p%22%2C%22default_home%22%3A%22%22%2C%22feed_menu%22%3A%5B%22Popular%22%2C%22Trending%22%5D%2C%22related_videos%22%3Atrue%2C%22sort%22%3A%22published%22%2C%22speed%22%3A1.0%2C%22thin_mode%22%3Afalse%2C%22unseen_only%22%3Afalse%2C%22video_loop%22%3Afalse%2C%22extend_desc%22%3Afalse%2C%22volume%22%3A50%2C%22save_player_pos%22%3Afalse%7D" +// document.cookie = "PREFS=%7B%22annotations%22%3Atrue%2C%22annotations_subscribed%22%3Afalse%2C%22autoplay%22%3Atrue%2C%22automatic_instance_redirect%22%3Atrue%2C%22captions%22%3A%5B%22%22%2C%22%22%2C%22%22%5D%2C%22comments%22%3A%5B%22youtube%22%2C%22reddit%22%5D%2C%22continue%22%3Afalse%2C%22continue_autoplay%22%3Atrue%2C%22dark_mode%22%3A%22light%22%2C%22latest_only%22%3Afalse%2C%22listen%22%3Afalse%2C%22local%22%3Atrue%2C%22watch_history%22%3Afalse%2C%22vr_mode%22%3Atrue%2C%22show_nick%22%3Afalse%2C%22locale%22%3A%22en-US%22%2C%22region%22%3A%22US%22%2C%22max_results%22%3A40%2C%22notifications_only%22%3Afalse%2C%22player_style%22%3A%22invidious%22%2C%22quality%22%3A%22dash%22%2C%22quality_dash%22%3A%221080p%22%2C%22default_home%22%3A%22%22%2C%22feed_menu%22%3A%5B%22Popular%22%2C%22Trending%22%5D%2C%22related_videos%22%3Atrue%2C%22sort%22%3A%22published%22%2C%22speed%22%3A1.0%2C%22thin_mode%22%3Afalse%2C%22unseen_only%22%3Afalse%2C%22video_loop%22%3Afalse%2C%22extend_desc%22%3Afalse%2C%22volume%22%3A50%2C%22save_player_pos%22%3Afalse%7D" @@ -30,9 +30,9 @@ autoload -Uz compinit compinit -u # history -HISTSIZE=1000 +HISTSIZE=999999 +SAVEHIST=999999 HISTFILE=~/.zsh_history -SAVEHIST=1000 HISTDUP=erase setopt INC_APPEND_HISTORY setopt HIST_IGNORE_ALL_DUPS |