commit 47e051301bc6be594590dc90dff71582dfab7239 parent 5c12df51d15c84fe3f06bd55fe12dcb60a413b96 Author: hhvn <dev@hhvn.uk> Date: Wed, 2 Aug 2023 22:08:53 +0100 Rename .scripts to .bin Diffstat:
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 -}