dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

commit 47e051301bc6be594590dc90dff71582dfab7239
parent 5c12df51d15c84fe3f06bd55fe12dcb60a413b96
Author: hhvn <dev@hhvn.uk>
Date:   Wed,  2 Aug 2023 22:08:53 +0100

Rename .scripts to .bin

Diffstat:
R.scripts/addrbook -> .bin/addrbook | 0
R.scripts/asplit -> .bin/asplit | 0
R.scripts/backronym -> .bin/backronym | 0
R.scripts/colotable -> .bin/colotable | 0
R.scripts/convf -> .bin/convf | 0
A.bin/crypto | 2++
R.scripts/cst2secs -> .bin/cst2secs | 0
R.scripts/currency -> .bin/currency | 0
R.scripts/deexif -> .bin/deexif | 0
R.scripts/dgrep -> .bin/dgrep | 0
R.scripts/diary -> .bin/diary | 0
R.scripts/dmarc -> .bin/dmarc | 0
R.scripts/dnsbl -> .bin/dnsbl | 0
A.bin/dpass | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
R.scripts/dupfind -> .bin/dupfind | 0
R.scripts/dwmbar/Makefile -> .bin/dwmbar/Makefile | 0
A.bin/dwmbar/dwmbar | 46++++++++++++++++++++++++++++++++++++++++++++++
R.scripts/dwmbar/restart -> .bin/dwmbar/restart | 0
R.scripts/encsign -> .bin/encsign | 0
R.scripts/fetchmail -> .bin/fetchmail | 0
R.scripts/gdiffpager -> .bin/gdiffpager | 0
R.scripts/geo -> .bin/geo | 0
R.scripts/getascii -> .bin/getascii | 0
R.scripts/gophcheck -> .bin/gophcheck | 0
R.scripts/gopherdl -> .bin/gopherdl | 0
R.scripts/gpgimport -> .bin/gpgimport | 0
R.scripts/hvol -> .bin/hvol | 0
R.scripts/imgclean -> .bin/imgclean | 0
R.scripts/infowall -> .bin/infowall | 0
R.scripts/lsswp -> .bin/lsswp | 0
R.scripts/mailselect -> .bin/mailselect | 0
R.scripts/manualpatch -> .bin/manualpatch | 0
R.scripts/markwatched -> .bin/markwatched | 0
R.scripts/mkmaildir -> .bin/mkmaildir | 0
R.scripts/mvmailbackup -> .bin/mvmailbackup | 0
R.scripts/net/addwpa -> .bin/net/addwpa | 0
R.scripts/net/autoconf -> .bin/net/autoconf | 0
R.scripts/net/autoconf-bond -> .bin/net/autoconf-bond | 0
R.scripts/net/bandcamp/bandcampsrch -> .bin/net/bandcamp/bandcampsrch | 0
R.scripts/net/bandcamp/dl -> .bin/net/bandcamp/dl | 0
R.scripts/net/download -> .bin/net/download | 0
R.scripts/net/rhosts -> .bin/net/rhosts | 0
R.scripts/net/scan -> .bin/net/scan | 0
R.scripts/notify -> .bin/notify | 0
R.scripts/notify-send -> .bin/notify-send | 0
R.scripts/openbsd-compat/aliases -> .bin/openbsd-compat/aliases | 0
R.scripts/openbsd-compat/seq -> .bin/openbsd-compat/seq | 0
R.scripts/openbsd-compat/sha256sum -> .bin/openbsd-compat/sha256sum | 0
A.bin/openbsd-compat/sha512sum | 2++
R.scripts/openbsd-compat/shuf -> .bin/openbsd-compat/shuf | 0
R.scripts/openbsd-compat/tac -> .bin/openbsd-compat/tac | 0
R.scripts/passgpg -> .bin/passgpg | 0
R.scripts/passgpg2 -> .bin/passgpg2 | 0
A.bin/paste/hhgph | 18++++++++++++++++++
R.scripts/pexelgrab -> .bin/pexelgrab | 0
A.bin/plumb | 272+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
R.scripts/pman -> .bin/pman | 0
R.scripts/qmv -> .bin/qmv | 0
R.scripts/queuevid -> .bin/queuevid | 0
R.scripts/quik -> .bin/quik | 0
R.scripts/rfclookup -> .bin/rfclookup | 0
R.scripts/rm/patch -> .bin/rm/patch | 0
R.scripts/rm/sshsockets -> .bin/rm/sshsockets | 0
R.scripts/scrape/atom -> .bin/scrape/atom | 0
R.scripts/scrape/debug -> .bin/scrape/debug | 0
R.scripts/scrape/youtube -> .bin/scrape/youtube | 0
R.scripts/screenoff -> .bin/screenoff | 0
R.scripts/secs2cst -> .bin/secs2cst | 0
R.scripts/service -> .bin/service | 0
R.scripts/sfeed_addfeed -> .bin/sfeed_addfeed | 0
A.bin/slock_mod | 6++++++
R.scripts/slopvid -> .bin/slopvid | 0
R.scripts/somafm -> .bin/somafm | 0
R.scripts/srxsrch -> .bin/srxsrch | 0
R.scripts/sshtar -> .bin/sshtar | 0
R.scripts/sttab -> .bin/sttab | 0
R.scripts/sudo -> .bin/sudo | 0
R.scripts/tag/clear -> .bin/tag/clear | 0
A.bin/tag/clearalbum_artist | 8++++++++
R.scripts/tag/clearsort -> .bin/tag/clearsort | 0
R.scripts/tag/cover/set -> .bin/tag/cover/set | 0
R.scripts/tag/cover/view -> .bin/tag/cover/view | 0
R.scripts/tag/dirformat -> .bin/tag/dirformat | 0
R.scripts/tag/dirformatmv -> .bin/tag/dirformatmv | 0
R.scripts/tag/fileformat -> .bin/tag/fileformat | 0
R.scripts/tag/fileformatmv -> .bin/tag/fileformatmv | 0
R.scripts/tag/get -> .bin/tag/get | 0
R.scripts/tag/interactive -> .bin/tag/interactive | 0
R.scripts/tag/set -> .bin/tag/set | 0
R.scripts/textdisplay -> .bin/textdisplay | 0
R.scripts/thesaurus -> .bin/thesaurus | 0
R.scripts/tlds -> .bin/tlds | 0
R.scripts/tmuxkillshell -> .bin/tmuxkillshell | 0
R.scripts/topen -> .bin/topen | 0
R.scripts/torlist -> .bin/torlist | 0
R.scripts/torrents -> .bin/torrents | 0
R.scripts/tsclean -> .bin/tsclean | 0
R.scripts/uniqfind -> .bin/uniqfind | 0
R.scripts/uptimemon -> .bin/uptimemon | 0
R.scripts/urlencode -> .bin/urlencode | 0
R.scripts/urlhand -> .bin/urlhand | 0
R.scripts/urlhand2 -> .bin/urlhand2 | 0
R.scripts/wallblur -> .bin/wallblur | 0
R.scripts/wallp -> .bin/wallp | 0
R.scripts/wbcachemake -> .bin/wbcachemake | 0
R.scripts/wordle -> .bin/wordle | 0
R.scripts/yt/embedify -> .bin/yt/embedify | 0
R.scripts/yt/feed -> .bin/yt/feed | 0
R.scripts/yt/meta -> .bin/yt/meta | 0
R.scripts/yt/search -> .bin/yt/search | 0
R.scripts/yt/sorted -> .bin/yt/sorted | 0
D.scripts/bin | 2--
D.scripts/crypto | 2--
D.scripts/dpass | 61-------------------------------------------------------------
D.scripts/dwmbar/dwmbar | 46----------------------------------------------
D.scripts/hlpaste | 18------------------
D.scripts/openbsd-compat/sha512sum | 2--
D.scripts/plumb | 274-------------------------------------------------------------------------------
D.scripts/slock_mod | 29-----------------------------
D.scripts/tag/clearalbum_artist | 8--------
120 files changed, 426 insertions(+), 442 deletions(-)

diff --git a/.scripts/addrbook b/.bin/addrbook diff --git a/.scripts/asplit b/.bin/asplit diff --git a/.scripts/backronym b/.bin/backronym diff --git a/.scripts/colotable b/.bin/colotable diff --git a/.scripts/convf b/.bin/convf diff --git a/.bin/crypto b/.bin/crypto @@ -0,0 +1 @@ +currency +\ No newline at end of file diff --git a/.scripts/cst2secs b/.bin/cst2secs diff --git a/.scripts/currency b/.bin/currency diff --git a/.scripts/deexif b/.bin/deexif diff --git a/.scripts/dgrep b/.bin/dgrep diff --git a/.scripts/diary b/.bin/diary diff --git a/.scripts/dmarc b/.bin/dmarc diff --git a/.scripts/dnsbl b/.bin/dnsbl diff --git a/.bin/dpass b/.bin/dpass @@ -0,0 +1,72 @@ +#!/bin/rc +# Copyright (c) 2022 hhvn <dev@hhvn.uk> + +if (~ $#PASS 0) { + PASS = $home/.local/pass +} +if (!test -f $PASS) { + touch $PASS +} + +dec = `''{dmenu -P -p 'Master password:' </dev/null | gpg -qd --passphrase-fd 0 $PASS} + +if (!~ $#* 0) { + opt = $1 + fromarg = 1 +} else { + opt = `$nl{printf '%s' $dec | awk -F: 'BEGIN {printf("GENERATE\nAPPEND\nEDIT\n")}; {print $1}' | dmenu -l 20 -i} +} + +switch ($opt) { +case GENERATE + newpass = `''{tr -dc 'a-zA-Z0-9~!@#$%^&*_+=-' < /dev/urandom | head -c 35} + newname = `$nl{dmenu -p 'Name:' </dev/null} + if (~ $newname '') { + herbe 'dpass exiting... no pass given' + exit 1 + } + dec = `''{printf '%s%s: %s\n' $dec $newname $newpass} + encfile = /tmp/$pid.plain + touch $encfile + chmod 0700 $encfile + printf '%s' $dec > $encfile + gpg --armor -e --default-recipient-self < $encfile > $PASS + shred -u $encfile + printf '%s' $newpass | xclip + @{ sleep 25; xclip </dev/null } & +case APPEND + newname = `$nl{dmenu -p 'Name:' </dev/null} + newpass = `$nl{dmenu -P -p 'Password:' </dev/null} + if (~ $newname '') { + herbe 'dpass exiting... no pass given' + exit 1 + } + dec = `''{printf '%s%s: %s\n' $dec $newname $newpass} + encfile = /tmp/$pid.plain + touch $encfile + chmod 0700 $encfile + printf '%s' $dec > $encfile + gpg --armor -e --default-recipient-self < $encfile > $PASS + shred -u $encfile + printf '%s' $newpass | xclip + @{ sleep 25; xclip </dev/null } & +case EDIT + encfile = /tmp/$pid.plain + touch $encfile + chmod 0700 $encfile + printf '%s' $dec > $encfile + if (~ $EDITOR ()) { EDITOR=vim } + $EDITOR $encfile + gpg --armor -e --default-recipient-self < $encfile > $PASS + shred -u $encfile + printf '%s' $newpass | xclip + @{ sleep 25; xclip </dev/null } & +case * + out = `$nl{printf '%s' $dec | awk -F: -v 'opt=' ^ $opt '$1 == opt { print $2 }' | sed 's/^.//'} + if (~ $fromarg 1) { + echo $out + } else { + printf '%s' $out | xclip + @{ sleep 25; xclip </dev/null } & + } +} diff --git a/.scripts/dupfind b/.bin/dupfind diff --git a/.scripts/dwmbar/Makefile b/.bin/dwmbar/Makefile diff --git a/.bin/dwmbar/dwmbar b/.bin/dwmbar/dwmbar @@ -0,0 +1,46 @@ +#!/bin/rc + +cd `{dirname $0} + +mkdir -p /tmp/blocks +cd /tmp/blocks + +fn block { + val = `$nl{dwmbar/$1} { + if (~ $val () || ~ $val '') { + rm /tmp/blocks/$1 + } else { + printf '%s' $val > /tmp/blocks/$1 + } + } & +} + +fn sigexit { + for (p in $apids) { + kill $p + } +} + +block vol +while (true) { + block bat + block cpu + block mem + sleep 3 +} & + +while (true) { + block time + sleep 1 +} & + +while (true) { + block date + sleep 900 +} & + +printf ' ' > sep +while (true) { + sleep 0.1 + xsetroot -name ``(''){cat bat sep cpu sep mem sep date sep time sep >[2]/dev/null | tr -d '\n'} +} diff --git a/.scripts/dwmbar/restart b/.bin/dwmbar/restart diff --git a/.scripts/encsign b/.bin/encsign diff --git a/.scripts/fetchmail b/.bin/fetchmail diff --git a/.scripts/gdiffpager b/.bin/gdiffpager diff --git a/.scripts/geo b/.bin/geo diff --git a/.scripts/getascii b/.bin/getascii diff --git a/.scripts/gophcheck b/.bin/gophcheck diff --git a/.scripts/gopherdl b/.bin/gopherdl diff --git a/.scripts/gpgimport b/.bin/gpgimport diff --git a/.scripts/hvol b/.bin/hvol diff --git a/.scripts/imgclean b/.bin/imgclean diff --git a/.scripts/infowall b/.bin/infowall diff --git a/.scripts/lsswp b/.bin/lsswp diff --git a/.scripts/mailselect b/.bin/mailselect diff --git a/.scripts/manualpatch b/.bin/manualpatch diff --git a/.scripts/markwatched b/.bin/markwatched diff --git a/.scripts/mkmaildir b/.bin/mkmaildir diff --git a/.scripts/mvmailbackup b/.bin/mvmailbackup diff --git a/.scripts/net/addwpa b/.bin/net/addwpa diff --git a/.scripts/net/autoconf b/.bin/net/autoconf diff --git a/.scripts/net/autoconf-bond b/.bin/net/autoconf-bond diff --git a/.scripts/net/bandcamp/bandcampsrch b/.bin/net/bandcamp/bandcampsrch diff --git a/.scripts/net/bandcamp/dl b/.bin/net/bandcamp/dl diff --git a/.scripts/net/download b/.bin/net/download diff --git a/.scripts/net/rhosts b/.bin/net/rhosts diff --git a/.scripts/net/scan b/.bin/net/scan diff --git a/.scripts/notify b/.bin/notify diff --git a/.scripts/notify-send b/.bin/notify-send diff --git a/.scripts/openbsd-compat/aliases b/.bin/openbsd-compat/aliases diff --git a/.scripts/openbsd-compat/seq b/.bin/openbsd-compat/seq diff --git a/.scripts/openbsd-compat/sha256sum b/.bin/openbsd-compat/sha256sum diff --git a/.bin/openbsd-compat/sha512sum b/.bin/openbsd-compat/sha512sum @@ -0,0 +1 @@ +sha256sum +\ No newline at end of file diff --git a/.scripts/openbsd-compat/shuf b/.bin/openbsd-compat/shuf diff --git a/.scripts/openbsd-compat/tac b/.bin/openbsd-compat/tac diff --git a/.scripts/passgpg b/.bin/passgpg diff --git a/.scripts/passgpg2 b/.bin/passgpg2 diff --git a/.bin/paste/hhgph b/.bin/paste/hhgph @@ -0,0 +1,18 @@ +#!/bin/sh +# usage: <command> | hlpaste [file extension] +# hlpaste [file extension] < /path/to/file + +cp /dev/stdin /tmp/hlpaste +id=$(sha512sum < /tmp/hlpaste | grep -Eo '^.{15}') +fileext="${1:-txt}" +gtype=$(file /tmp/hlpaste | + tr '[:upper:]' '[:lower:]' | + sed -E 's~.*(binary|video|audio).*~9~;s~.*image.*~I~' | + grep -o '^.$' || echo "0") + +file="$id.$fileext" +path="$HOME/net/gopher/paste/$file" +uri="gopher://hhvn.uk/$gtype/paste/$file" +mv /tmp/hlpaste "$path" + +echo "$uri" | tee /dev/stderr | tr -d '\n' | xclip diff --git a/.scripts/pexelgrab b/.bin/pexelgrab diff --git a/.bin/plumb b/.bin/plumb @@ -0,0 +1,272 @@ +#!/bin/sh + +echo(){ + printf '%s\n' "$*" +} + +matches(){ + echo "$arg" | grep -Ei "$@" >/dev/null +} + +fmatches(){ + file "$arg" | grep -Ei "$@" >/dev/null +} + +fmagic(){ + isfile "$arg" || return 1 + grep "$1" < "$arg" >/dev/null +} + +_envsubst(){ + str="$*" + + env | + while read -r line + do + str=$(echo "$str" | awk -v "var=${line%%=*}" -v "val=${line#*=}" ' + { + regex = sprintf("\\$%s", var) + gsub(regex, val) + print + }' + ) + echo "$str" + done | tail -n 1 +} + +plumb(){ + t="$1"; shift + [ $norun -eq 1 ] && return + export norun=1 + case "$t" in + gui) + >/dev/null 2>/dev/null nohup sh -c "$*; rm '$file'" & + ;; + terminal) + >/dev/null 2>/dev/null nohup ${TERMINAL:-st} sh -c "$*; rm '$file'" & + ;; + prompt) + >/dev/null 2>/dev/null nohup ${TERMINAL:-st} sh -c "$(dmenu -i -p "$*"); rm '$file'" & + ;; + matchlater) + export norun=0 + >/dev/null 2>/dev/null nohup sh -c "$*" & + ;; + *) + herbe "No such plumb-type: $t" + ;; + esac +} + +replace(){ + arg=$(echo "$arg" | sed "$*") +} + +isfile(){ + [ -z "$1" ] && { + [ -f "$arg" ] + return $? + } + [ -n "$1" ] && { + [ -f "$1" ] + return $? + } +} + +hascmd(){ + command -v "$*" >/dev/null +} + +wasfetched(){ + [ -n "$orig" ] +} + +fetch(){ + file="/tmp/plumb.$(basename "$arg")" + while [ -f $file ] + do + file="/tmp/plumb.$(base64 </dev/urandom | tr -d / | head -c10).$(basename "$arg")" + done + $proxy curl $([ "$verbose" != "y" ] && echo -s) "$(echo "$arg" | sed -E 's/]|\[|}|\{/\\&/g')" > "$file" + export orig="$arg" + export arg="$file" + removelater "$file" +} + +removelater(){ + [ -z "$exittrap" ] && exittrap="$*" + exittrap="$exittrap; rm -rf \"$*\"" + trap "$exittrap" EXIT +} + +mime(){ + mime=$($proxy curl -Li$([ "$verbose" != "y" ] && echo s) "$(echo "$arg" | sed -E 's/]|\[|}|\{/\\&/g')" | + awk '/^HTTP/ && $2 != "200" {s=1}; /^HTTP/ && $2 == "200" {p=1}; /^[[:space:]]*$/ {if (s) s=0; else exit 1}; p' | + tr '[:upper:]' '[:lower:]' | awk '$1 == "content-type:" {print $2}') + echo "$mime" | tee /dev/stderr | grep -i "$1" >/dev/null +} + +case "$1" in + -v) + verbose=y + shift + ;; +esac + +[ -n "$PLUMB" ] && exit +export PLUMB="$$" + +for arg in "$@" +do + export norun=0 + export gui=0 + export proxy="" + export arg + export orig="" + + # remove file:// + matches "^file://" && + replace 's~^file://~~' + + # network + matches "://.*\.onion" && + export proxy="torsocks" + + matches "^magnet:" && + plumb terminal 'addtorrent "$arg"' + + matches "^(gopher|http)s?://.*\.(ogg|mp3|opus|flac|pls)$" && + plumb terminal '$proxy mpv --pause $arg' + + matches "^(gopher|http)s?://.*\.gif$" && + plumb gui '$proxy mpv --loop-file $arg' + + matches "(youtu.be|youtube.com).*/feeds/" && + plumb gui 'sfeed_addfeed "$arg"' + + matches "^(gopher|http)s?://.*\.(mkv|mp4|avi|webm|ogv|gifv|mp4|ape|m3u|m3u8)$" || + matches "^https?://(www\.|m\.)?(youtube.com|youtu.be)" && + plumb gui '$proxy mpv --pause "$arg"' + + matches "^https?://" && + ! mime "text/html" && + fetch + + matches "^https?://" || + matches "\.html?$" || + fmatches "HTML" && + plumb gui 'qutebrowser $arg' + + matches "^gophers?://(.*/[17+0](/|$)|[^/]*$)" && + plumb terminal '$proxy zygo $arg' + + matches "^gophers?://" && + fetch + + matches "^mailto:" && + plumb terminal 'neomutt $(echo "$arg" | sed "s~^mailto:~~")' + + matches "^finger://" && + plumb terminal '$proxy finger $(echo "$arg" | sed "s~^finger://~~"); cat' + + matches "^ssh://" && + plumb terminal '$proxy ssh $(echo "$arg" | sed "s~^ssh://~~;s~:[0-9]*~~")' + + matches "^git://" && + plumb terminal '$proxy git clone $arg' + + # local files now + fmatches "gzip" && + isfile && + plumb matchlater 'gunzip < $arg > $arg.new && mv $arg.new $arg' && + removelater "$arg.new" + + fmatches "zip.*archive" && + isfile + plumb matchlater 'unzip -p $arg > $arg.new && mv $arg.new $arg' && + removelater "$arg.new" + + fmatches "PGP.*public.*key|PGP.*ring" && + isfile && + plumb terminal 'gpg --import $arg; sleep 5' + + fmatches "PGP.*signature" && + isfile && + plumb terminal 'gpg --verify $arg; sleep 5' + + fmatches "PGP.*message|PGP.*encrypted" && + isfile && + plumb terminal 'gpg -d $arg; sleep 5' + + matches ".*\.(epub|ps|eps|pdf|dvi|djvu)$" || + fmatches "pdf|postscript" && + isfile && + plumb gui 'zathura $arg' + + matches ".*\.gif$" && + isfile && + plumb gui 'mpv --loop-file $arg' + + matches ".*\.(mkv|mp4|avi|webm|ogg|ogv|gifv|mp3|mp4|opus|flac|ape|m3u|m3u8)$" || + fmatches "video|matroska|audio|sound" && + isfile && + plumb terminal 'mpv --pause $arg' + + matches ".*\.(jpe?g|gif|tiff?|ppm|bit|bmp|png|xpm)$" || + fmatches "image" && + isfile && + plumb gui 'sxiv $arg' + + matches "\.?/.*\.[0-9]p?$" && + fmatches "(roff|preprocessor)" && + isfile && + plumb terminal 'man $arg' + + matches "\.(gph|gophermap)$|(^|/)gophermap$" && + isfile && + plumb terminal 'cgo -f $arg' + + matches "\.(atom|rss)$|rss\.xml$|atom\.xml$" || + fmatches "atom|rss" || + fmagic "<feed.*xmlns.*http://www.w3.org/2005/Atom" || + fmagic "<rss" && + wasfetched && + plumb gui 'sfeed_addfeed $orig' + + matches "\.(atom|rss)$|rss\.xml$" || + fmatches "atom|rss" || + fmagic "<feed.*xmlns.*http://www.w3.org/2005/Atom" || + fmagic "<rss" && + ! wasfetched && + plumb terminal 'sfeed < $arg | sort -rn | sfeed_curses' + + # dmarc reports + fmagic "<feedback" && + fmagic "<policy_published" && + fmagic "<dkim" && + plumb terminal 'dmarc < $arg; cat' + + # numbered file + matches ":[0-9][0-9]*$" && + isfile ${arg%:*} && + plumb terminal 'vim +${arg##*:} ${arg%:*}' + + # catch all for files + matches ".*" && + isfile && + plumb terminal 'vim $arg' + + # include files + matches ".*\.h$" && + isfile "/usr/include/$arg" && + plumb terminal 'vim /usr/include/$arg' + + matches ".*\.h$" && + isfile "/usr/local/include/$arg" && + plumb terminal 'vim /usr/local/include/$arg' + + # catch-all for non-files + matches ".*" && + plumb prompt 'Plumb to (use $arg): ' +done +wait diff --git a/.scripts/pman b/.bin/pman diff --git a/.scripts/qmv b/.bin/qmv diff --git a/.scripts/queuevid b/.bin/queuevid diff --git a/.scripts/quik b/.bin/quik diff --git a/.scripts/rfclookup b/.bin/rfclookup diff --git a/.scripts/rm/patch b/.bin/rm/patch diff --git a/.scripts/rm/sshsockets b/.bin/rm/sshsockets diff --git a/.scripts/scrape/atom b/.bin/scrape/atom diff --git a/.scripts/scrape/debug b/.bin/scrape/debug diff --git a/.scripts/scrape/youtube b/.bin/scrape/youtube diff --git a/.scripts/screenoff b/.bin/screenoff diff --git a/.scripts/secs2cst b/.bin/secs2cst diff --git a/.scripts/service b/.bin/service diff --git a/.scripts/sfeed_addfeed b/.bin/sfeed_addfeed diff --git a/.bin/slock_mod b/.bin/slock_mod @@ -0,0 +1,6 @@ +#!/bin/sh + +cmus-remote --pause-playback +xset dpms force off + +slock -m "Locked" diff --git a/.scripts/slopvid b/.bin/slopvid diff --git a/.scripts/somafm b/.bin/somafm diff --git a/.scripts/srxsrch b/.bin/srxsrch diff --git a/.scripts/sshtar b/.bin/sshtar diff --git a/.scripts/sttab b/.bin/sttab diff --git a/.scripts/sudo b/.bin/sudo diff --git a/.scripts/tag/clear b/.bin/tag/clear diff --git a/.bin/tag/clearalbum_artist b/.bin/tag/clearalbum_artist @@ -0,0 +1,8 @@ +#!/bin/rc +# +# Grrr. +# + +for (f in $*) { + tag/clear $f album_artist +} diff --git a/.scripts/tag/clearsort b/.bin/tag/clearsort diff --git a/.scripts/tag/cover/set b/.bin/tag/cover/set diff --git a/.scripts/tag/cover/view b/.bin/tag/cover/view diff --git a/.scripts/tag/dirformat b/.bin/tag/dirformat diff --git a/.scripts/tag/dirformatmv b/.bin/tag/dirformatmv diff --git a/.scripts/tag/fileformat b/.bin/tag/fileformat diff --git a/.scripts/tag/fileformatmv b/.bin/tag/fileformatmv diff --git a/.scripts/tag/get b/.bin/tag/get diff --git a/.scripts/tag/interactive b/.bin/tag/interactive diff --git a/.scripts/tag/set b/.bin/tag/set diff --git a/.scripts/textdisplay b/.bin/textdisplay diff --git a/.scripts/thesaurus b/.bin/thesaurus diff --git a/.scripts/tlds b/.bin/tlds diff --git a/.scripts/tmuxkillshell b/.bin/tmuxkillshell diff --git a/.scripts/topen b/.bin/topen diff --git a/.scripts/torlist b/.bin/torlist diff --git a/.scripts/torrents b/.bin/torrents diff --git a/.scripts/tsclean b/.bin/tsclean diff --git a/.scripts/uniqfind b/.bin/uniqfind diff --git a/.scripts/uptimemon b/.bin/uptimemon diff --git a/.scripts/urlencode b/.bin/urlencode diff --git a/.scripts/urlhand b/.bin/urlhand diff --git a/.scripts/urlhand2 b/.bin/urlhand2 diff --git a/.scripts/wallblur b/.bin/wallblur diff --git a/.scripts/wallp b/.bin/wallp diff --git a/.scripts/wbcachemake b/.bin/wbcachemake diff --git a/.scripts/wordle b/.bin/wordle diff --git a/.scripts/yt/embedify b/.bin/yt/embedify diff --git a/.scripts/yt/feed b/.bin/yt/feed diff --git a/.scripts/yt/meta b/.bin/yt/meta diff --git a/.scripts/yt/search b/.bin/yt/search diff --git a/.scripts/yt/sorted b/.bin/yt/sorted diff --git a/.scripts/bin b/.scripts/bin @@ -1 +0,0 @@ -. -\ No newline at end of file diff --git a/.scripts/crypto b/.scripts/crypto @@ -1 +0,0 @@ -currency -\ No newline at end of file diff --git a/.scripts/dpass b/.scripts/dpass @@ -1,61 +0,0 @@ -#!/bin/rc -# Copyright (c) 2022 hhvn <dev@hhvn.uk> - -if (~ $#PASS 0) { - PASS = $home/.local/pass -} -if (!test -f $PASS) { - touch $PASS -} - -dec = `''{dmenu -P -p 'Master password:' </dev/null | gpg -qd --passphrase-fd 0 $PASS} - -if (!~ $#* 0) { - opt = $1 - fromarg = 1 -} else { - opt = `$nl{printf '%s' $dec | awk -F: 'BEGIN {printf("GENERATE\nAPPEND\n")}; {print $1}' | dmenu -l 20 -i} -} - -switch ($opt) { -case GENERATE - newpass = `''{tr -dc 'a-zA-Z0-9~!@#$%^&*_+=-' < /dev/urandom | head -c 35} - newname = `$nl{dmenu -p 'Name:' </dev/null} - if (~ $newname '') { - herbe 'dpass exiting... no pass given' - exit 1 - } - dec = `''{printf '%s%s: %s\n' $dec $newname $newpass} - encfile = /tmp/$pid.plain - touch $encfile - chmod 0700 $encfile - printf '%s' $dec > $encfile - gpg --armor -e --default-recipient-self < $encfile > $PASS - shred -u $encfile - printf '%s' $newpass | xclip - @{ sleep 25; xclip </dev/null } & -case APPEND - newname = `$nl{dmenu -p 'Name:' </dev/null} - newpass = `$nl{dmenu -P -p 'Password:' </dev/null} - if (~ $newname '') { - herbe 'dpass exiting... no pass given' - exit 1 - } - dec = `''{printf '%s%s: %s\n' $dec $newname $newpass} - encfile = /tmp/$pid.plain - touch $encfile - chmod 0700 $encfile - printf '%s' $dec > $encfile - gpg --armor -e --default-recipient-self < $encfile > $PASS - shred -u $encfile - printf '%s' $newpass | xclip - @{ sleep 25; xclip </dev/null } & -case * - out = `$nl{printf '%s' $dec | awk -F: -v 'opt=' ^ $opt '$1 == opt { print $2 }' | sed 's/^.//'} - if (~ $fromarg 1) { - echo $out - } else { - printf '%s' $out | xclip - @{ sleep 25; xclip </dev/null } & - } -} diff --git a/.scripts/dwmbar/dwmbar b/.scripts/dwmbar/dwmbar @@ -1,46 +0,0 @@ -#!/bin/rc - -cd `{dirname $0} - -mkdir -p /tmp/blocks -cd /tmp/blocks - -fn block { - val = `$nl{dwmbar/$1} { - if (~ $val () || ~ $val '') { - rm /tmp/blocks/$1 - } else { - printf '%s' $val > /tmp/blocks/$1 - } - } & -} - -fn sigexit { - for (p in $apids) { - kill $p - } -} - -block vol -while (true) { - block bat - block cpu - block mem - sleep 3 -} & - -while (true) { - block time - sleep 1 -} & - -while (true) { - block date - sleep 900 -} & - -printf ' ' > sep -while (true) { - sleep 0.1 - xsetroot -name ``(''){cat bat sep cpu sep mem sep vol sep date sep time sep >[2]/dev/null | tr -d '\n'} -} diff --git a/.scripts/hlpaste b/.scripts/hlpaste @@ -1,18 +0,0 @@ -#!/bin/sh -# usage: <command> | hlpaste [file extension] -# hlpaste [file extension] < /path/to/file - -cp /dev/stdin /tmp/hlpaste -id=$(sha512sum < /tmp/hlpaste | grep -Eo '^.{15}') -fileext="${1:-txt}" -gtype=$(file /tmp/hlpaste | - tr '[:upper:]' '[:lower:]' | - sed -E 's~.*(binary|video|audio).*~9~;s~.*image.*~I~' | - grep -o '^.$' || echo "0") - -file="$id.$fileext" -path="$HOME/net/paste/$file" -uri="gopher://hhvn.uk/$gtype/paste/$file" -mv /tmp/hlpaste "$path" - -echo "$uri" | tee /dev/stderr | tr -d '\n' | xclip diff --git a/.scripts/openbsd-compat/sha512sum b/.scripts/openbsd-compat/sha512sum @@ -1 +0,0 @@ -sha256sum -\ No newline at end of file diff --git a/.scripts/plumb b/.scripts/plumb @@ -1,274 +0,0 @@ -#!/bin/sh - -echo(){ - printf '%s\n' "$*" -} - -matches(){ - echo "$arg" | grep -Ei "$@" >/dev/null -} - -fmatches(){ - file "$arg" | grep -Ei "$@" >/dev/null -} - -fmagic(){ - isfile "$arg" || return 1 - grep "$1" < "$arg" >/dev/null -} - -_envsubst(){ - str="$*" - - env | - while read -r line - do - str=$(echo "$str" | awk -v "var=${line%%=*}" -v "val=${line#*=}" ' - { - regex = sprintf("\\$%s", var) - gsub(regex, val) - print - }' - ) - echo "$str" - done | tail -n 1 -} - -plumb(){ - t="$1"; shift - [ $norun -eq 1 ] && return - export norun=1 - case "$t" in - gui) - >/dev/null 2>/dev/null nohup sh -c "$*; rm '$file'" & - ;; - terminal) - >/dev/null 2>/dev/null nohup ${TERMINAL:-st} sh -c "$*; rm '$file'" & - ;; - prompt) - >/dev/null 2>/dev/null nohup ${TERMINAL:-st} sh -c "$(dmenu -i -p "$*"); rm '$file'" & - ;; - matchlater) - export norun=0 - >/dev/null 2>/dev/null nohup sh -c "$*" & - ;; - *) - herbe "No such plumb-type: $t" - ;; - esac -} - -replace(){ - arg=$(echo "$arg" | sed "$*") -} - -isfile(){ - [ -z "$1" ] && { - [ -f "$arg" ] - return $? - } - [ -n "$1" ] && { - [ -f "$1" ] - return $? - } -} - -hascmd(){ - command -v "$*" >/dev/null -} - -wasfetched(){ - [ -n "$orig" ] -} - -fetch(){ - file="/tmp/plumb.$(basename "$arg")" - while [ -f $file ] - do - file="/tmp/plumb.$(base64 </dev/urandom | tr -d / | head -c10).$(basename "$arg")" - done - $proxy curl $([ "$verbose" != "y" ] && echo -s) "$(echo "$arg" | sed -E 's/]|\[|}|\{/\\&/g')" > "$file" - export orig="$arg" - export arg="$file" - removelater "$file" -} - -removelater(){ - [ -z "$exittrap" ] && exittrap="$*" - exittrap="$exittrap; rm -rf \"$*\"" - trap "$exittrap" EXIT -} - -mime(){ - mime=$($proxy curl -Li$([ "$verbose" != "y" ] && echo s) "$(echo "$arg" | sed -E 's/]|\[|}|\{/\\&/g')" | - awk '/^HTTP/ && $2 != "200" {s=1}; /^HTTP/ && $2 == "200" {p=1}; /^[[:space:]]*$/ {if (s) s=0; else exit 1}; p' | - tr '[:upper:]' '[:lower:]' | awk '$1 == "content-type:" {print $2}') - echo "$mime" | tee /dev/stderr | grep -i "$1" >/dev/null -} - -case "$1" in - -v) - verbose=y - shift - ;; -esac - -[ -n "$PLUMB" ] && exit -export PLUMB="$$" - -for arg in "$@" -do - export norun=0 - export gui=0 - export proxy="" - export arg=$(_envsubst "$arg") - export orig="" - - # remove file:// - matches "^file://" && - replace 's~^file://~~' - - # network - matches "://.*\.onion" && - export proxy="torsocks" - - matches "^magnet:" && - plumb terminal 'addtorrent "$arg"' - - matches "^(gopher|http)s?://.*\.(ogg|mp3|opus|flac|pls)$" && - plumb terminal '$proxy mpv --pause $arg' - - matches "^(gopher|http)s?://.*\.gif$" && - plumb gui '$proxy mpv --loop-file $arg' - - matches "(youtu.be|youtube.com).*/feeds/" && - plumb gui 'sfeed_addfeed "$arg"' - - matches "^(gopher|http)s?://.*\.(mkv|mp4|avi|webm|ogv|gifv|mp4|ape|m3u|m3u8)$" || - matches "^https?://(www\.|m\.)?(youtube.com|youtu.be)" || - matches "^https?://.*/videos/watch/" || # peertube - matches "^https?://videos?\..*/w/" && # peertube also uses /w/, which is so ambiguous I made this subdomain-dependant - plumb gui 'queuevid "$arg" && $proxy mpv --pause "$arg"' - - matches "^https?://" && - ! mime "text/html" && - fetch - - matches "^https?://" || - matches "\.html?$" || - fmatches "HTML" && - plumb gui 'qutebrowser $arg' - - matches "^gophers?://(.*/[17+0](/|$)|[^/]*$)" && - plumb terminal '$proxy zygo $arg' - - matches "^gophers?://" && - fetch - - matches "^mailto:" && - plumb terminal 'neomutt $(echo "$arg" | sed "s~^mailto:~~")' - - matches "^finger://" && - plumb terminal '$proxy finger $(echo "$arg" | sed "s~^finger://~~"); cat' - - matches "^ssh://" && - plumb terminal '$proxy ssh $(echo "$arg" | sed "s~^ssh://~~;s~:[0-9]*~~")' - - matches "^git://" && - plumb terminal '$proxy git clone $arg' - - # local files now - fmatches "gzip" && - isfile && - plumb matchlater 'gunzip < $arg > $arg.new && mv $arg.new $arg' && - removelater "$arg.new" - - fmatches "zip.*archive" && - isfile - plumb matchlater 'unzip -p $arg > $arg.new && mv $arg.new $arg' && - removelater "$arg.new" - - fmatches "PGP.*public.*key|PGP.*ring" && - isfile && - plumb terminal 'gpg --import $arg; sleep 5' - - fmatches "PGP.*signature" && - isfile && - plumb terminal 'gpg --verify $arg; sleep 5' - - fmatches "PGP.*message|PGP.*encrypted" && - isfile && - plumb terminal 'gpg -d $arg; sleep 5' - - matches ".*\.(epub|ps|eps|pdf|dvi|djvu)$" || - fmatches "pdf|postscript" && - isfile && - plumb gui 'zathura $arg' - - matches ".*\.gif$" && - isfile && - plumb gui 'mpv --loop-file $arg' - - matches ".*\.(mkv|mp4|avi|webm|ogg|ogv|gifv|mp3|mp4|opus|flac|ape|m3u|m3u8)$" || - fmatches "video|matroska|audio|sound" && - isfile && - plumb terminal 'mpv --pause $arg' - - matches ".*\.(jpe?g|gif|tiff?|ppm|bit|bmp|png|xpm)$" || - fmatches "image" && - isfile && - plumb gui 'sxiv $arg' - - matches "\.?/.*\.[0-9]p?$" && - fmatches "(roff|preprocessor)" && - isfile && - plumb terminal 'man $arg' - - matches "\.(gph|gophermap)$|(^|/)gophermap$" && - isfile && - plumb terminal 'cgo -f $arg' - - matches "\.(atom|rss)$|rss\.xml$|atom\.xml$" || - fmatches "atom|rss" || - fmagic "<feed.*xmlns.*http://www.w3.org/2005/Atom" || - fmagic "<rss" && - wasfetched && - plumb gui 'sfeed_addfeed $orig' - - matches "\.(atom|rss)$|rss\.xml$" || - fmatches "atom|rss" || - fmagic "<feed.*xmlns.*http://www.w3.org/2005/Atom" || - fmagic "<rss" && - ! wasfetched && - plumb terminal 'sfeed < $arg | sort -rn | sfeed_curses' - - # dmarc reports - fmagic "<feedback" && - fmagic "<policy_published" && - fmagic "<dkim" && - plumb terminal 'dmarc < $arg; cat' - - # numbered file - matches ":[0-9][0-9]*$" && - isfile ${arg%:*} && - plumb terminal 'vim +${arg##*:} ${arg%:*}' - - # catch all for files - matches ".*" && - isfile && - plumb terminal 'vim $arg' - - # include files - matches ".*\.h$" && - isfile "/usr/include/$arg" && - plumb terminal 'vim /usr/include/$arg' - - matches ".*\.h$" && - isfile "/usr/local/include/$arg" && - plumb terminal 'vim /usr/local/include/$arg' - - # catch-all for non-files - matches ".*" && - plumb prompt 'Plumb to (use $arg): ' -done -wait diff --git a/.scripts/slock_mod b/.scripts/slock_mod @@ -1,29 +0,0 @@ -#!/bin/sh -socket1="$1" -socket2="$2" -socket3="$3" - -cmus-remote --pause-playback -xset dpms force off -echo "dmpv/rmpv: $(hmpv state $socket1)" > ~/.cache/socket -echo "dmpvurl: $(hmpv state $socket2)" >> ~/.cache/socket -( - hmpv pause $socket1 - sleep 0.2 - hmpv pause $socket2 - hvol toggle -) & -export LC_ALL=c - -# slock -m "$(figlet -f $(find /usr/share/figlet/ -name "*.flf" | sed 's/\.flf$//;s~.*/~~' | shuf | head -n 1) locked)" - -slock -m "$(doas 2>&1)" - -# slock -m "$(infowall | sed "s/$(printf "\033")[^m]*m//g;/^Colours/d")" - -state=$(cat ~/.cache/socket | awk '/:/') -state1=$(echo "$state" | head -n -1 | awk '{print $2}') -state2=$(echo "$state" | tail +2 | awk '{print $2}') -[ "$state1" = "playing" ] && hmpv unpause $socket1 -[ "$state2" = "playing" ] && hmpv unpause $socket2 -hvol toggle diff --git a/.scripts/tag/clearalbum_artist b/.scripts/tag/clearalbum_artist @@ -1,8 +0,0 @@ -#!/bin/rc -# -# Grrr. -# - -for (f in *) { - tag/clear $f album_artist -}