dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit ae1c4166246f8e7372007e5c846ea6fb53062fc1
parent bcb1f70187fd0c574b8611e314e1332d0fa9e011
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun,  7 Jun 2020 21:20:29 +0200

Use torsocks for all onion targets

Diffstat:
M.local/bin/plumb | 32++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -2,6 +2,7 @@ version=0.1 calendar="$HOME/.calendar/calendar" +prefix="" show_help() { echo "usage: ${0##*/} [OPTIONS] [FILE|URL]" @@ -54,9 +55,6 @@ termopen() { fetch() { _o="$(mktemp)" - if regeximatch "$1" "\.onion"; then - prefix=torsocks - fi err="" if command -v hurl >/dev/null 2>&1; then $prefix hurl "$1" > "$_o" 2> /tmp/plumb_err @@ -163,6 +161,12 @@ handle_target() { else + if regeximatch "$t" "\.onion"; then + prefix=torsocks + else + prefix= + fi + case "$t" in *scholar.google.*) t="$(printf '%s' "$t" | \ @@ -192,28 +196,24 @@ handle_target() { fi if regeximatch "$t" '\.(mp4|mkv|webm|avi|ogv)$'; then - detach mpv "$t" + detach $prefix mpv "$t" elif regeximatch "$t" '^radio://'; then - mpv "http${t##radio}" + $prefix mpv "http${t##radio}" elif regeximatch "$t" '\.(mp3|ogg|m3u)$'; then - mpv "$(fetch "$t")" + $prefix mpv "$(fetch "$t")" elif regeximatch "$t" '\.(png|jpg|jpeg|tif|bmp|gif)$'; then - sxiv "$(fetch "$t")" + $prefix sxiv "$(fetch "$t")" elif regeximatch "$t" '\.(pdf|ps|epub|djvu)$'; then - zathura "$(fetch "$t")" + $prefix zathura "$(fetch "$t")" elif regeximatch "$t" '(smbc-comics\.com|xkcd\.com|jspowerhour\.com)'; then cd /tmp && detach comic "$t" elif regexmatch "$t" '.*doi.*10\.[0-9]*\/'; then - detach $BROWSER "https://doi.org/${t}" + detach $prefix $BROWSER "https://doi.org/${t}" elif regexmatch "$t" '\.(txt|patch|diff|rst|md)$'; then f="$(fetch "$t")" termopen less "$f" elif regeximatch "$t" '^gopher://'; then - if regeximatch "$t" "\.onion"; then - termopen torsocks sacc "$t" - else - termopen sacc "$t" - fi + termopen $prefix sacc "$t" elif regexmatch "$t" '[A-z]\.[0-9]$'; then if [ -z "$TERM" ]; then detach $TERMINAL mandoc -l "$(fetch "$t")" @@ -221,10 +221,10 @@ handle_target() { mandoc -l "$(fetch "$t")" fi elif regeximatch "$t" '(youtube\.|youtu\.be|vimeo\.com|invidious\.snopyta\.org)'; then - cd ~/tmp && detach mpv "$t" + cd ~/tmp && detach $prefix mpv "$t" elif regeximatch "$t" '^(http|https)://' || \ regeximatch "$t" '\.webp$'; then - detach $BROWSER "$t" + detach $prefix $BROWSER "$t" else die "unknown target type: $t" fi