From 6a0745dedbe3bdd87f5430c41d05587feb469953 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 17:36:14 +0100 Subject: [PATCH 1/8] qutebrowser: Extend page redirection Extended redirection using open source frontends for a variety of services: youtube, reddit, lbry, twitter, google translate and more. --- qutebrowser/.config/qutebrowser/config.py | 3 +- qutebrowser/.config/qutebrowser/redirects.py | 209 ++++++++++++++++++ .../qutebrowser/{url.py => searchengines.py} | 38 +--- 3 files changed, 212 insertions(+), 38 deletions(-) create mode 100644 qutebrowser/.config/qutebrowser/redirects.py rename qutebrowser/.config/qutebrowser/{url.py => searchengines.py} (57%) diff --git a/qutebrowser/.config/qutebrowser/config.py b/qutebrowser/.config/qutebrowser/config.py index 2c8974f..fa11210 100644 --- a/qutebrowser/.config/qutebrowser/config.py +++ b/qutebrowser/.config/qutebrowser/config.py @@ -45,7 +45,8 @@ c.downloads.location.prompt = False config.source("alias.py") config.source("maps.py") config.source("content.py") -config.source("url.py") +config.source("searchengines.py") +config.source("redirects.py") # Tab-Bar # have tab bar on the right, not on the top diff --git a/qutebrowser/.config/qutebrowser/redirects.py b/qutebrowser/.config/qutebrowser/redirects.py new file mode 100644 index 0000000..48fccca --- /dev/null +++ b/qutebrowser/.config/qutebrowser/redirects.py @@ -0,0 +1,209 @@ +import random +import re +from qutebrowser.api import interceptor + +redirects = { + "youtube": { + "source": ["youtube.com"], + "target": [ + "yt.oelrichsgarcia.de", + "vid.priv.au", + "invidious.weblibre.org", + "invidious.dhusch.de", + "iv.ggtyler.dev", + "invidious.baczek.me", + "yt.funami.tech", + "iv.melmac.space", + "invidious.silur.me", + "inv.riverside.rocks", + "invidious.lidarshield.cloud", + "invidious.flokinet.to", + "invidious.snopyta.org", + "invidious.kavin.rocks", + "vid.puffyan.us", + "yt.artemislena.eu", + "invidious.nerdvpn.de", + "invidious.tiekoetter.com", + "invidious.namazso.eu", + "inv.vern.cc", + "yewtu.be", + "inv.bp.projectsegfau.lt", + "invidious.epicsite.xyz", + "y.com.sb", + "invidious.sethforprivacy.com", + ], + }, + "lbry": { + "source": ["odysee.com"], + "target": [ + "lbry.bcow.xyz", + "odysee.076.ne.jp", + "librarian.pussthecat.org", + "lbry.mutahar.rocks", + "librarian.esmailelbob.xyz", + "lbry.vern.cc", + ], + }, + "reddit": { + "source": ["reddit.com"], + "target": [ + "td.vern.cc", + "teddit.adminforge.de", + "teddit.artemislena.eu", + "teddit.bus-hit.me", + "teddit.froth.zone", + "teddit.hostux.net", + "teddit.namazso.eu", + "teddit.net", + "teddit.pussthecat.org", + "teddit.sethforprivacy.com", + "teddit.totaldarkness.net", + "teddit.zaggy.nl", + ], + }, + "twitter": { + "source": ["twitter.com"], + "target": [ + "nitter.net", + "nitter.42l.fr", + "nitter.pussthecat.org", + "nitter.fdn.fr", + "nitter.1d4.us", + "nitter.kavin.rocks", + "nitter.unixfox.eu", + "nitter.namazso.eu", + "nitter.moomoo.me", + "bird.trom.tf", + "nitter.it", + "twitter.censors.us", + "nitter.grimneko.de", + "twitter.076.ne.jp", + "n.l5.ca", + "unofficialbird.com", + "nitter.ungovernable.men", + ], + }, + "imdb": { + "source": ["imdb.com"], + "target": [ + "libremdb.iket.me", + "libremdb.pussthecat.org", + "libremdb.esmailelbob.xyz", + "ld.vern.cc", + "binge.whatever.social", + "libremdb.lunar.icu", + ], + }, + "translate": { + "source": ["translate.google.com"], + "target": [ + "lingva.ml", + "translate.igna.wtf", + "translate.plausibility.cloud", + "translate.projectsegfau.lt", + "translate.dr460nf1r3.org", + "lingva.garudalinux.org", + "translate.jae.fi", + ], + }, + "tiktok": { + "source": ["tiktok.com"], + "target": [ + "proxitok.pabloferreiro.es", + "proxitok.pussthecat.org", + "tok.habedieeh.re", + "proxitok.esmailelbob.xyz", + "proxitok.privacydev.net", + "proxitok.odyssey346.dev", + "tok.artemislena.eu", + "tok.adminforge.de", + "proxitok.manasiwibi.com", + "tik.hostux.net", + "tt.vern.cc", + "proxitok.mha.fi", + "proxitok.pufe.org", + "proxitok.marcopisco.com", + "cringe.whatever.social", + "proxitok.lunar.icu", + ], + }, + "imgur": { + "source": ["imgur.com"], + "target": [ + "rimgo.bcow.xyz", + "rimgo.pussthecat.org", + "rimgo.totaldarkness.net", + "rimgo.bus-hit.me", + "rimgo.esmailelbob.xyz", + "imgur.artemislena.eu", + "rimgo.vern.cc", + "rim.odyssey346.dev", + "rimgo.privacytools.io", + "i.habedieeh.re", + "rimgo.hostux.net", + "ri.zzls.xyz", + "rimgo.marcopisco.com", + "rimgo.lunar.icu", + ], + }, + "medium": { + "source": ["medium.com"], + "target": [ + "scribe.rip", + "scribe.nixnet.services", + "scribe.citizen4.eu", + "scribe.bus-hit.me", + "scribe.froth.zone", + "scribe.esmailelbob.xyz", + "scribe.privacydev.net", + "sc.vern.cc", + ], + }, + "google": { + "source": ["google.com"], + "target": [ + "whoogle.dcs0.hu", + ], + }, + "wikipedia": { + "source": ["wikipedia.org"], + "target": [ + "wiki.adminforge.de", + "wiki.froth.zone", + "wiki.slipfox.xyz", + "wikiless.esmailelbob.xyz", + "wikiless.funami.tech", + "wikiless.northboot.xyz", + "wikiless.org", + "wikiless.tiekoetter.com", + "wl.vern.cc", + ], + }, +} + +def rewrite(request: interceptor.Request): + if ( + request.resource_type != interceptor.ResourceType.main_frame + or request.request_url.scheme() in {"data", "blob"} + ): + return + + url = request.request_url + + for service in redirects.values(): + matched=False + for source in service["source"]: + if re.search(source, url.host()): + matched=True + + if matched: + target = service["target"][random.randint(0, len(service["target"]))] + if target is not None and url.setHost(target) is not False: + try: + request.redirect(url) + except: + pass + break + + +interceptor.register(rewrite) diff --git a/qutebrowser/.config/qutebrowser/url.py b/qutebrowser/.config/qutebrowser/searchengines.py similarity index 57% rename from qutebrowser/.config/qutebrowser/url.py rename to qutebrowser/.config/qutebrowser/searchengines.py index 852501a..473a132 100644 --- a/qutebrowser/.config/qutebrowser/url.py +++ b/qutebrowser/.config/qutebrowser/searchengines.py @@ -1,5 +1,3 @@ -from qutebrowser.api import interceptor - c.url.searchengines = { "sci": "https://sci-hub.ru/{}", "DEFAULT": "https://search.martyoeh.me/?q={}", @@ -24,41 +22,7 @@ c.url.searchengines = { "r": "https://www.reddit.com/r/{}", "t": "https://www.thesaurus.com/browse/{}", "w": "https://en.wikipedia.org/w/index.php?search={}", - "yt": "https://www.youtube.com/results?search_query={}", + "yt": "https://invidious.weblibre.org/search?q={}", } c.url.default_page = "https://start.duckduckgo.com" c.url.start_pages = ["https://start.duckduckgo.com"] - -redirects = { - "reddit.com": "teddit.net", - "www.reddit.com": "teddit.net", - "youtube.com": "yewtu.be", - "www.youtube.com": "www.yewtu.be", - "twitter.com": "nitter.net", - "www.twitter.com": "nitter.net", - "instagram.com": "bibliogram.art", - "www.instagram.com": "bibliogram.art", - "wikipedia.org": "wikiless.org", - "en.wikipedia.org": "wikiless.org", - "medium.com": "scribe.rip", -} - - -def rewrite(request: interceptor.Request): - if ( - request.resource_type != interceptor.ResourceType.main_frame - or request.request_url.scheme() in {"data", "blob"} - ): - return - - url = request.request_url - - redir = redirects.get(url.host()) - if redir is not None and url.setHost(redir) is not False: - try: - request.redirect(url) - except: - pass - - -interceptor.register(rewrite) From d56d0148f6b16b0288dfba348c59e20c1c06374a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 18:42:42 +0100 Subject: [PATCH 2/8] bootstrap: Fix initial package installation to work --- README.md | 12 ++- bootstrap/install_packages.sh | 21 ++--- bootstrap/system-packages/etc/pacman.conf | 100 ++++++++++++++++++++++ install.sh | 30 ++++--- 4 files changed, 135 insertions(+), 28 deletions(-) create mode 100644 bootstrap/system-packages/etc/pacman.conf diff --git a/README.md b/README.md index dd9116f..b228628 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,17 @@ The current dotfiles are geared toward wayland for which the setup looks similar The dotfiles use `GNU stow` to link themselves in the home directory. You can clone this repository anywhere (though I have mine in `~/.dotfiles` as it seemed most logical for me). -I would recommend doing a `git clone --recursive` for this repository, since it contains git [submodules](https://nering.dev/2016/git-submodules-vs-subtrees/), which will then automatically get pulled in as well. Of course, you can do it non-recursively and then just pull those modules selectively which you actually want. +I would recommend doing an initial `git clone --recursive` for this repository, since it contains git [submodules](https://nering.dev/2016/git-submodules-vs-subtrees/), which will then automatically get pulled in as well. +Of course, you can do it non-recursively and then just pull those modules selectively which you actually want. Once in the repository directory, when you then run `./install.sh` it will install many of the packages I use (though they are probably slightly out-of-date) and link the dotfiles into the home directory. -If you do not want to install any packages, but only link the dotfiles run `stow -S */` from the main repository directory. -Since dotfiles management is based on `stow`, it will not overwrite anything already in the home directory (though you can force it to if you really want, using `stow --override='.*'` -- I do not recommend this). +I would mostly recommend this on fresh machines or a test machine first - it *will* link my personal dotfiles and, if you allow it, *will* install quite a few packages. +By default it will ask your consent for some steps -- use `./install.sh -f` to force yes to everything. + +The dotfile installation procedure is based on `stow`, it will *not overwrite* anything already in the home directory (though you can force it to if you really want, using `stow --override='.*'` -- I do not recommend this). + +> **NOTE** +> The same non-destructive installation procedure does *not* apply to the package installation and system setting file linking, where it can potentially overwrite or remove existing files. After all files are linked and you open a new shell session, the `dotlink` alias will allow you to re-link all dotfiles from anywhere on the system.[^1] diff --git a/bootstrap/install_packages.sh b/bootstrap/install_packages.sh index 4f812fb..4608b6e 100755 --- a/bootstrap/install_packages.sh +++ b/bootstrap/install_packages.sh @@ -7,7 +7,9 @@ # DESCRIPTION: Display usage information for this script. # PARAMETERS: see usage function #============================================================================== -packages="${BOOTSTRAP_PACKAGES:-packages.txt}" +PKG_TSV_FILE=${PKG_TSV_FILE:-bootstrap/packages.tsv} +packages_repo="${BOOTSTRAP_PACKAGES:-$(grep -e ' R ' "$PKG_TSV_FILE" | cut -f1 -d' ' )}" +packages_aur="${BOOTSTRAP_PACKAGES_AUR:-$(grep -e ' A ' "$PKG_TSV_FILE" | cut -f1 -d' ' )}" main() { local cmd="" @@ -60,27 +62,16 @@ update_repos() { install_packages() { unattended="$1" if "$unattended"; then - yay -Squ --noconfirm --needed - <"$packages" + echo "$packages_repo" "$packages_aur" | yay -Squ --noconfirm --needed - else - yay -Su --needed - <"$packages" - fi -} - -check_consent() { - echo "This will take a while and install many packages. Proceed [y/N]?" - read -r yes - if [[ "$yes" != y* ]]; then - echo "Exiting." - exit + echo "$packages_repo" | yay -Squ --needed - + echo "$packages_aur" | yay -S --needed - fi } install() { unattended=$1 echo "Beginning package bootstrap ..............................................." - if ! "$unattended"; then - check_consent - fi echo "Installing yay ............................................................" install_yay echo "Installing apps ..........................................................." diff --git a/bootstrap/system-packages/etc/pacman.conf b/bootstrap/system-packages/etc/pacman.conf new file mode 100644 index 0000000..922ac08 --- /dev/null +++ b/bootstrap/system-packages/etc/pacman.conf @@ -0,0 +1,100 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +Architecture = auto + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +UseSyslog +Color +#NoProgressBar +CheckSpace +VerbosePkgLists +ParallelDownloads = 5 + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +# NOTE: You must run `pacman-key --init` before first using pacman; the local +# keyring can then be populated with the keys of all official Arch Linux +# packagers with `pacman-key --populate archlinux`. + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +# The testing repositories are disabled by default. To enable, uncomment the +# repo name header and Include lines. You can add preferred servers immediately +# after the header, and they will be used before the default mirrors. + +#[testing] +#Include = /etc/pacman.d/mirrorlist + +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +#[community-testing] +#Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist + +# If you want to run 32 bit applications on your x86_64 system, +# enable the multilib repositories as required here. + +#[multilib-testing] +#Include = /etc/pacman.d/mirrorlist + +[multilib] +Include = /etc/pacman.d/mirrorlist + +# An example of a custom package repository. See the pacman manpage for +# tips on creating your own repositories. +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/custompkgs diff --git a/install.sh b/install.sh index 0dad27e..273981a 100755 --- a/install.sh +++ b/install.sh @@ -43,13 +43,12 @@ check_consent() { true else [[ "$1" == "y" ]] && default_consent="[Y/n]" || default_consent="[y/N]" - printf "%s %s " "$2" "$default_consent" + printf "%b %b " "$2" "$default_consent" read -r answer if [[ "$1" == "n" ]] && [[ "$answer" != y* ]]; then printf "%s\n" "$3" false elif [[ "$1" == "y" ]] && [[ "$answer" == n* ]]; then - echo second printf "%s\n" "$3" false else @@ -59,7 +58,7 @@ check_consent() { } entry_question() { - check_consent n "This will take a while, install many packages and link dotfiles all over the place. Proceed?" "Aborting." || exit + check_consent n "This will take a while and install many packages and link dotfiles all over the place depending on your selections.\nYou need to be in the base directory of the dotfiles repository.\nProceed?" "Aborting." || exit } enable_git_hooks() { @@ -80,21 +79,30 @@ stow_dotfiles() { echo "Linked dotfiles." } +run_elevated() { + if command -v doas >/dev/null 2>&1; then + doas "$@" + elif command -v sudo >/dev/null 2>&1; then + sudo "$@" + fi +} + stow_system_packages() { - check_consent n "Link system settings as well? This will require sudo access." "Not touching system files." || return - sudo stow --dir="$bootstrap_dir" --target="/" -R system-packages/ + check_consent n "Link system settings files? This will require sudo access and may overwrite existing files." "Not touching system files." || return + if [ -e "/etc/pacman.conf" ]; then + check_consent n "Found an existing pacman.conf file, installation will error if it exists. Remove file?" && run_elevated rm "/etc/pacman.conf" + fi + run_elevated stow --dir="$bootstrap_dir" --target="/" -R system-packages/ echo "Linked system files." } install_packages() { - check_consent n "Install pre-designated packages? This will take a while." "Not installing packages." || return - export BOOTSTRAP_PACKAGES="bootstrap/packages.txt" + check_consent n "Install pre-designated packages? This will take a while, install a lot of packages and require super user privileges." "Not installing packages." || return if ! "$UNATTENDED"; then "$bootstrap_dir"/install_packages.sh else "$bootstrap_dir"/install_packages.sh -f fi - unset BOOTSTRAP_PACKAGES echo "Installed packages." } @@ -104,12 +112,14 @@ install() { entry_question fi - echo "====================== BEGINNING INSTALLATION =============================" + echo "====================== BEGINNING SYSTEM FILE MANAGEMENT =============================" + stow_system_packages + + echo "====================== BEGINNING PACKAGE INSTALLATION =============================" install_packages echo "=================== BEGINNING DOTFILE MANAGEMENT ==========================" stow_dotfiles - stow_system_packages echo "================== ENABLING GIT REPOSITORY HOOKS ==========================" enable_git_hooks From 1a05ea84454625156b9b98e0569f0ee71afc2c72 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 18:47:47 +0100 Subject: [PATCH 3/8] bootstrap: Split packages into stable and testing lists Split the lists into two, with testing getting automatically updated on packages added (and removed, but only if the package to be removed is *not* in stable packages already). This way, I can always be sure that I have my stable setup in the repository, but packages that I am temporarily testing have a place without being forgotten and I can more easily change them around until they find a place in stable or get thrown out. --- .githooks/prepare-commit-msg | 2 +- .../{packages.tsv => packages_stable.tsv} | 7 ++- bootstrap/packages_testing.tsv | 7 +++ bootstrap/update_package_list.sh | 54 +++++++++++-------- 4 files changed, 43 insertions(+), 27 deletions(-) rename bootstrap/{packages.tsv => packages_stable.tsv} (98%) create mode 100644 bootstrap/packages_testing.tsv diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg index 410b6ca..c8a6b77 100755 --- a/.githooks/prepare-commit-msg +++ b/.githooks/prepare-commit-msg @@ -4,7 +4,7 @@ COMMIT_MSG_FILE="$1" COMMIT_SOURCE="$2" BOOTSTRAPDIR="bootstrap" -pkg_committed="$(cat $(git rev-parse --show-toplevel)/$BOOTSTRAPDIR/packages.tsv | tail +2 | cut -f1 | sort)" +pkg_committed="$(cat "$(git rev-parse --show-toplevel)"/$BOOTSTRAPDIR/packages*.tsv | grep -v -e '^Name Description Source Target' | cut -f1 | sort)" pkg_onsystem=$(pacman -Qqett | grep -v "$(pacman -Qqg base-devel)" | sort) # get files only in repo, and only on machine diff --git a/bootstrap/packages.tsv b/bootstrap/packages_stable.tsv similarity index 98% rename from bootstrap/packages.tsv rename to bootstrap/packages_stable.tsv index 30da719..ce731dd 100644 --- a/bootstrap/packages.tsv +++ b/bootstrap/packages_stable.tsv @@ -69,7 +69,6 @@ ffmpegthumbnailer Lightweight video thumbnailer that can be used by file manager firefox Standalone web browser from mozilla.org R fonts-cjk Linux 下的免费商用字体包 A freerdp Free implementation of the Remote Desktop Protocol (RDP) R -fvextra Extensions to fancyvrb, including automatic line breaking and improved math mode R fwupd Simple daemon to allow session software to update firmware R fzf-tab-bin-git Replace zsh's default completion selection menu with fzf (git version). This package also compiles the optional binary module. A gallery-dl Command-line program to download image-galleries and collections from several image hosting sites A @@ -107,7 +106,6 @@ iputils Network monitoring tools, including ping R ipython An enhanced Interactive Python shell. R iucode-tool Tool to manipulate Intel® IA-32/X86-64 microcode bundles R iwd Internet Wireless Daemon R -jabref-latest GUI frontend for BibTeX, written in Java; latest main (master) version from git A jiq-bin Interactive JSON query tool using jq expressions A jmtpfs FUSE and libmtp based filesystem for accessing MTP (Media Transfer Protocol) devices A jpdftweak A Swiss Army Knife GUI application for PDF documents A @@ -147,6 +145,7 @@ maim Utility to take a screenshot using imlib2 R mako Lightweight notification daemon for Wayland R man-db A utility for reading man pages R man-pages Linux man pages R +markdownlint-cli MarkdownLint Command Line Interface A masterpdfeditor-free A complete solution for creation and editing PDF files - Free version without watermark A mbsync-git free (GPL) mailbox synchronization program A mediainfo Supplies technical and tag information about a video or audio file (CLI interface) R @@ -183,7 +182,6 @@ newsboat RSS/Atom feed reader for text terminals R nextcloud-client Nextcloud desktop client R nfs-utils Support programs for Network File Systems R nmap Utility for network discovery and security auditing R -nodejs-markdownlint-cli MarkdownLint Command Line Interface A nodejs-pandiff Prose diffs for any document format supported by Pandoc A noto-fonts-emoji Google Noto emoji fonts R npm A package manager for javascript R @@ -312,12 +310,13 @@ vagrant Build and distribute virtualized development environments R vale-bin A customizable, syntax-aware linter for prose A vdirsyncer Synchronize CalDAV and CardDAV. R viddy A modern watch command A -vifm-git Ncurses based file manager with vi like keybindings A +vifm A file manager with curses interface, which provides Vi[m]-like environment R vim-language-server VimScript language server A virt-manager Desktop user interface for managing virtual machines R virtualbox Powerful x86 virtualization for enterprise as well as home use R virtualbox-guest-iso The official VirtualBox Guest Additions ISO image R visidata Terminal spreadsheet multitool for discovering and arranging data R +wallabag-client Command line client for the self hosted read-it-later app Wallabag A wavemon Ncurses-based monitoring application for wireless network devices R waybar Highly customizable Wayland bar for Sway and Wlroots based compositors R waylock-git A simple screenlocker for Wayland compositors A diff --git a/bootstrap/packages_testing.tsv b/bootstrap/packages_testing.tsv new file mode 100644 index 0000000..081b461 --- /dev/null +++ b/bootstrap/packages_testing.tsv @@ -0,0 +1,7 @@ +Name Description Source Target +most A terminal pager similar to 'more' and 'less' R +netbird-bin A WireGuard-based mesh network that connects your devices into a single private network A +odysseyra1n Bootstraps Procursus and install Sileo/libhooker on devices jailbroken with checkra1n. A +shadow-tech Desktop client for Shadow Tech cloud gaming service. A +signal-desktop Signal Private Messenger for Linux R +vifm A file manager with curses interface, which provides Vi[m]-like environment R diff --git a/bootstrap/update_package_list.sh b/bootstrap/update_package_list.sh index 8d35bf0..bb37f4d 100755 --- a/bootstrap/update_package_list.sh +++ b/bootstrap/update_package_list.sh @@ -1,16 +1,18 @@ #!/usr/bin/env bash -BOOTSTRAP_DIR=~/.dotfiles/bootstrap -OUTPUT=${BOOTSTRAP_DIR}/packages.tsv +BOOTSTRAP_DIR=${BOOTSTRAP_DIR:-$(pwd)/bootstrap} +INPUTFILES=$(find "${BOOTSTRAP_DIR}" -type f -name 'packages*.tsv') +OUTPUTFILE=${BOOTSTRAP_DIR}/packages_testing.tsv pkg_all=$(pacman -Qqett | grep -v "$(pacman -Qqg base-devel)") pkg_repo=$(pacman -Qqn) pkg_aur=$(pacman -Qqm) -while getopts "nvh" opt; do +while getopts "nvhf:" opt; do case "$opt" in n) DRYRUN=true ;; v) VERBOSE=true ;; + f) OUTPUTFILE="$OPTARG" ;; h | *) { printf "\nUpdate the list of installed packages.\n\nWill compare packages committed to the dotfile repository\nand those currently installed (on an Arch system, using pacman).\nUpdates the list of committed packages in repository\nand prints out the differences as a diff.\n\nOptions:\n\n\t-h\tDisplay this help.\n\t-v\tShow verbose information.\n\t-n\tPrint out changes without changing anything (dry-run).\n" @@ -20,6 +22,13 @@ while getopts "nvh" opt; do esac done +# get all existing written packages +if [ -n "$INPUTFILES" ]; then + INPUT=$(cat $INPUTFILES | grep -v -e '^Name Description Source Target' | sort) +else + INPUT="" +fi + print_msg() { # shellcheck disable=2059 [ -n "$VERBOSE" ] && printf "$@" @@ -29,10 +38,10 @@ print_msg() { # packagename, description, source, target # toot a toot manager A D -if [ -f "${OUTPUT}_TEMP" ]; then - rm "${OUTPUT}_TEMP" +if [ -f "${OUTPUTFILE}_TEMP" ]; then + rm "${OUTPUTFILE}_TEMP" fi -touch "${OUTPUT}_TEMP" +touch "${OUTPUTFILE}_TEMP" # create new package list for pkg in $pkg_all; do @@ -52,9 +61,7 @@ for pkg in $pkg_all; do desc="${desc#"${desc%%[![:space:]]*}"}" target="" - if [ -f "$OUTPUT" ]; then - found_line=$(grep -e "^$pkg" "$OUTPUT") - fi + found_line=$(echo "$INPUT" | grep -e "^$pkg") if [ -n "$found_line" ]; then target=$(echo "$found_line" | cut -f4) print_msg "Updating pkg: %s:%s from: %s, for: %s\n" "$pkg" "$desc" "$source" "$target" @@ -62,26 +69,29 @@ for pkg in $pkg_all; do print_msg "Adding pkg: %s:%s from: %s, for: %s\n" "$pkg" "$desc" "$source" "$target" fi - printf "%s\t%s\t%s\t%s\n" "$pkg" "$desc" "$source" "$target" >>"${OUTPUT}_TEMP" + printf "%s\t%s\t%s\t%s\n" "$pkg" "$desc" "$source" "$target" >>"${OUTPUTFILE}_TEMP" done # notify on any removed packages -if [ -f "$OUTPUT" ]; then - while read -r line; do - if ! echo "$line" | cut -f1 | xargs -I _ grep -F -q -x _ <(echo "$pkg_all"); then - printf "REMOVED: %s\n" "$line" - fi - done <<<"$(tail +2 $OUTPUT)" -fi +while read -r line; do + if ! echo "$line" | cut -f1 | xargs -I _ grep -F -q -x _ <(echo "$pkg_all"); then + printf "REMOVED: %s\n" "$line" + fi +done <<<"<(echo $INPUT | tail +2)" # show file changes -if [ -f "$OUTPUT" ] && [ -f "$OUTPUT"_TEMP ]; then - changes=$(diff --color=always -y --suppress-common-lines "$OUTPUT" "$OUTPUT"_TEMP | tail -n+2) +if [ -f "$OUTPUTFILE"_TEMP ]; then + changes=$(diff --color=always -y --suppress-common-lines <(echo "$INPUT") <(sort "$OUTPUTFILE"_TEMP | tail -n+2)) printf "FILE CHANGES:\n=============\n%s" "$changes" fi -# actually write to file +# actually write changes to file if [ -z "$DRYRUN" ]; then - cat <(printf "Name\tDescription\tSource\tTarget\n") "${OUTPUT}_TEMP" >"$OUTPUT" + + while IFS= read -r line; do + sed -i -e "/^${line//\//\\/}$/d" "$OUTPUTFILE"_TEMP + done <<< "$INPUT" + + cat <(printf "Name\tDescription\tSource\tTarget\n") "${OUTPUTFILE}_TEMP" > "$OUTPUTFILE" fi -rm "${OUTPUT}_TEMP" +rm "${OUTPUTFILE}_TEMP" From df724c20ba7b53adb4df76a2468b2930e9098534 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 18:50:50 +0100 Subject: [PATCH 4/8] bootstrap: Add testing Dockerfile to bootstrap Added Dockerfile which sets up a simple archlinux test environment for the dotfiles/bootstrap process/playing around. Will simply build a simple archlinux machine with a single user. --- bootstrap/Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bootstrap/Dockerfile diff --git a/bootstrap/Dockerfile b/bootstrap/Dockerfile new file mode 100644 index 0000000..69e052f --- /dev/null +++ b/bootstrap/Dockerfile @@ -0,0 +1,22 @@ +FROM archlinux:latest + +# First build then run this dockerfile with: +# `podman build -t bootstrap .` +# `podman run -it -v /path/to/my/dotfiles:/path/to/my/dotfiles:ro bootstrap` + +RUN pacman-key --init +RUN pacman -Syu --noconfirm git vi base-devel sudo zsh man man-pages + +RUN useradd -m -G wheel -s /usr/bin/zsh marty +RUN echo "%wheel ALL=(ALL:ALL) ALL" >> /etc/sudoers +RUN echo "marty:password" | chpasswd + +# RUN su marty +# RUN cd /home/marty +# RUN git clone "https://git.martyoeh.me/Marty/dotfiles" .dotfiles +# link it directly from dotfile development dir to experiment + +USER marty +VOLUME /home/marty/.dotfiles +WORKDIR /home/marty/.dotfiles +CMD ["/usr/bin/bash"] From 565a356ea8e883bec39f25065c8d9784e99910f3 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 18:52:48 +0100 Subject: [PATCH 5/8] nvim: Add bibtex source to cmp autocompletion Added simple bibtex source display: Will show the bibtex entries existing in the bib file set through `bibliography: path/to/mine.bib`. Shows author, title, date on hovering. --- nvim/.config/nvim/lua/plug/_cmp.lua | 7 +++++-- nvim/.config/nvim/lua/plugins.lua | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/lua/plug/_cmp.lua b/nvim/.config/nvim/lua/plug/_cmp.lua index bad2eb5..b61ef7e 100644 --- a/nvim/.config/nvim/lua/plug/_cmp.lua +++ b/nvim/.config/nvim/lua/plug/_cmp.lua @@ -68,14 +68,17 @@ cmp.setup({ }, sources = cmp.config.sources({ { name = 'path' }, { name = 'nvim_lsp' }, { name = 'treesitter' }, - { name = 'tmux' }, { name = 'vsnip' }, { name = 'latex_symbols' }, - { name = 'vCard' }, { name = 'nvim_lua' } + { name = 'cmp_pandoc' }, { name = 'tmux' }, { name = 'vsnip' }, + { name = 'latex_symbols' }, { name = 'vCard' }, { name = 'nvim_lua' } }, { { name = 'buffer' }, { name = 'spell' } }) }) if vim.o.ft == 'clap_input' and vim.o.ft == 'guihua' and vim.o.ft == 'guihua_rust' then require 'cmp'.setup.buffer { completion = { enable = false } } end +-- set up pandoc bibtex source generation +require 'cmp_pandoc'.setup() + -- Use buffer source for `/` search cmp.setup.cmdline('/', { mapping = cmp.mapping.preset.cmdline(), diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 45ff9f5..388b2d0 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -236,6 +236,10 @@ require("packer").startup(function() } } + use { + 'aspeddro/cmp-pandoc.nvim', + requires = {'nvim-lua/plenary.nvim', 'jbyuki/nabla.nvim'} + } require('plug._cmp') -- Automatically set up your configuration after cloning packer.nvim From 50264c2eac8fd1ee4c72ae8ba8580ae3058aa73d Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 18:53:56 +0100 Subject: [PATCH 6/8] nvim: Format plugins file --- nvim/.config/nvim/lua/plugins.lua | 51 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 388b2d0..868ce6e 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,8 +1,12 @@ local ensure_packer = function() local fn = vim.fn - local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' + local install_path = fn.stdpath('data') .. + '/site/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }) + fn.system({ + 'git', 'clone', '--depth', '1', + 'https://github.com/wbthomason/packer.nvim', install_path + }) vim.cmd [[packadd packer.nvim]] return true end @@ -12,11 +16,11 @@ end local packer_bootstrap = ensure_packer() -- Compile on plugin edits -vim.api.nvim_create_autocmd({ "BufWritePost" }, { +vim.api.nvim_create_autocmd({"BufWritePost"}, { pattern = "plugins.lua", command = "PackerCompile", desc = "Compile plugins after editing plugin list", - group = vim.api.nvim_create_augroup('compilepackages', { clear = true }) + group = vim.api.nvim_create_augroup('compilepackages', {clear = true}) }) local use = require("packer").use @@ -38,7 +42,7 @@ require("packer").startup(function() use 'vifm/vifm.vim' -- integrate file manager use { 'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter - requires = { 'nvim-lua/plenary.nvim' }, + requires = {'nvim-lua/plenary.nvim'}, tag = 'release', config = function() require('plug._gitsigns') end, event = "BufRead" @@ -94,26 +98,26 @@ require("packer").startup(function() -- statusline use { 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true }, + requires = {'kyazdani42/nvim-web-devicons', opt = true}, config = function() require('plug._lualine') end } -- writing - use { 'vim-pandoc/vim-pandoc-syntax' } - use { 'vim-pandoc/vim-pandoc' } - use { 'vim-pandoc/vim-criticmarkup' } + use {'vim-pandoc/vim-pandoc-syntax'} + use {'vim-pandoc/vim-pandoc'} + use {'vim-pandoc/vim-criticmarkup'} use { "quarto-dev/quarto-vim", - requires = { { "vim-pandoc/vim-pandoc-syntax" } }, - ft = { "quarto" } + requires = {{"vim-pandoc/vim-pandoc-syntax"}}, + ft = {"quarto"} } use 'micarmst/vim-spellsync' -- personal dict improvements for git sync - use { 'folke/zen-mode.nvim', config = require('zen-mode').setup() } -- provide distraction free writing + use {'folke/zen-mode.nvim', config = require('zen-mode').setup()} -- provide distraction free writing use 'folke/twilight.nvim' -- provide even distraction free-er writing (lowlight paragraphs) use 'alok/notational-fzf-vim' -- quickly search through the wiki -- languages - use { 'euclidianAce/BetterLua.vim', ft = 'lua' } -- better syntax highlighting for lua + use {'euclidianAce/BetterLua.vim', ft = 'lua'} -- better syntax highlighting for lua use 'aliou/bats.vim' -- enable syntax for bats shell-code testing library -- REPL work @@ -134,7 +138,7 @@ require("packer").startup(function() 'hanschen/vim-ipython-cell', -- send code 'cells' to REPL ft = "python", config = function() - vim.g.ipython_cell_highlight_cells_ft = { 'python' } + vim.g.ipython_cell_highlight_cells_ft = {'python'} vim.g.ipython_cell_insert_tag = "## Cell" end } @@ -169,19 +173,19 @@ require("packer").startup(function() use { "nvim-telescope/telescope.nvim", requires = { - { "nvim-lua/popup.nvim" }, { "nvim-lua/plenary.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim", run = 'make' } + {"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"}, + {"nvim-telescope/telescope-fzf-native.nvim", run = 'make'} }, config = function() require('plug._telescope') end } use { 'protex/better-digraphs.nvim', - requires = { { "nvim-telescope/telescope.nvim" } } + requires = {{"nvim-telescope/telescope.nvim"}} } -- snippeting - use { "hrsh7th/vim-vsnip", event = "InsertEnter" } -- snippet engine - use { "rafamadriz/friendly-snippets", event = "InsertEnter" } -- many snippets + use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine + use {"rafamadriz/friendly-snippets", event = "InsertEnter"} -- many snippets -- treesitter use { @@ -194,7 +198,7 @@ require("packer").startup(function() use { 'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches config = function() - require 'nvim-treesitter.configs'.setup { + require'nvim-treesitter.configs'.setup { textsubjects = { enable = true, keymaps = { @@ -221,7 +225,7 @@ require("packer").startup(function() use 'ray-x/lsp_signature.nvim' use { 'ray-x/navigator.lua', - requires = { 'ray-x/guihua.lua', run = 'cd lua/fzy && make' }, + requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}, config = function() require('plug._lsp') end } -- and completion @@ -233,7 +237,6 @@ require("packer").startup(function() 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-nvim-lua', 'kdheepak/cmp-latex-symbols', 'ray-x/cmp-treesitter', 'f3fora/cmp-spell', 'cbarrete/completion-vcard' - } } use { @@ -244,7 +247,5 @@ require("packer").startup(function() -- Automatically set up your configuration after cloning packer.nvim -- Put this at the end after all plugins - if packer_bootstrap then - require('packer').sync() - end + if packer_bootstrap then require('packer').sync() end end) From c985841776e360a3e778f996691e34d8f2318c76 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 21:59:00 +0100 Subject: [PATCH 7/8] office: Add basic khard configuration I am using card (in conjunction with my vdirsyncer setup) to quickly get an overview of my contacts and use them for email sending. This adds a very simple config to the repo which gets khard up and running. --- office/.config/khard/khard.conf | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 office/.config/khard/khard.conf diff --git a/office/.config/khard/khard.conf b/office/.config/khard/khard.conf new file mode 100644 index 0000000..4f79ede --- /dev/null +++ b/office/.config/khard/khard.conf @@ -0,0 +1,49 @@ +[addressbooks] +[[contacts]] +path = ~/documents/contacts/myconts + +[general] +debug = no +default_action = list +# These are either strings or comma seperated lists +editor = nvim +merge_editor = nvim, -d + +[contact table] +# display names by first or last name: first_name / last_name / formatted_name +display = first_name +# group by address book: yes / no +group_by_addressbook = no +# reverse table ordering: yes / no +reverse = no +# append nicknames to name column: yes / no +show_nicknames = no +# show uid table column: yes / no +show_uids = yes +# show kind table column: yes / no +show_kinds = no +# sort by first or last name: first_name / last_name / formatted_name +sort = first_name +# localize dates: yes / no +localize_dates = yes +# set a comma separated list of preferred phone number types in descending priority +# or nothing for non-filtered alphabetical order +preferred_phone_number_type = pref, cell, home +# set a comma separated list of preferred email address types in descending priority +# or nothing for non-filtered alphabetical order +preferred_email_address_type = pref, work, home + +[vcard] +# extend contacts with your own private objects +# these objects are stored with a leading "X-" before the object name in the vcard files +# every object label may only contain letters, digits and the - character +# example: +# private_objects = Jabber, Skype, Twitter +# default: , (the empty list) +private_objects = Jabber, Skype, Twitter +# preferred vcard version: 3.0 / 4.0 +preferred_version = 3.0 +# Look into source vcf files to speed up search queries: yes / no +search_in_source_files = no +# skip unparsable vcard files: yes / no +skip_unparsable = no From 9cd5fe3f993b7964a855b57a271b28c623a9155b Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 16 Jan 2023 22:01:07 +0100 Subject: [PATCH 8/8] sh: Add simple sc-im alias Added `sc` as alias for sc-im since typing the dash every time is cumbersome. --- sh/.config/sh/alias | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index c71d8f4..5c64994 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -124,3 +124,7 @@ fi if exist distrobox; then alias db=distrobox fi + +if exist sc-im; then + alias sc=sc-im +fi