dotfiles

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

commit c3e7d30e6aed1195c5005db771206401b63ee0f7
parent 38691481c400bc517a27f2483758f883c4af09c8
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 26 Feb 2021 13:46:50 +0100

plumb: use hurl(1) pipe for gophers:// media

Diffstat:
M.local/bin/plumb | 26++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -3,6 +3,14 @@ calendar="$HOME/.calendar/calendar" prefix="" +if command -v hurl >/dev/null 2>&1; then + fetcher="hurl" +elif command -v curl >/dev/null 2>&1; then + fetcher="curl -sL" +else + die 'could not find hurl or curl' +fi + show_help() { printf "usage: %s [OPTIONS] [FILE|URL ..]" "${0##*/}" echo "will open FILE or URL." @@ -47,12 +55,10 @@ termopen() { fetch() { _o="$(mktemp)" - if command -v hurl >/dev/null 2>&1 && ! regeximatch "$1" '^ftp:' ; then - $prefix hurl "$1" > "$_o" 2> /tmp/plumb_err - elif command -v curl >/dev/null 2>&1; then - $prefix curl -sL "$1" > "$_o" 2> /tmp/plumb_err + if ! regeximatch "$1" '^ftp:' ; then + $prefix $fetcher "$1" > "$_o" 2> /tmp/plumb_err else - die 'could not find hurl or curl' + $prefix curl -sL "$1" > "$_o" 2> /tmp/plumb_err fi if [ $? -ne 0 ]; then msg="could not fetch $1\\n\\n$(cat /tmp/plumb_err)" @@ -213,10 +219,12 @@ handle_url() { fi if regeximatch "$t" '^radio://'; then $prefix mpv --force-window=no "http${t##radio}" - elif regeximatch "$t" '^gophers://'; then - termopen $prefix plumb "$(fetch "$t")" elif regeximatch "$t" '\.(mp4|mkv|webm|avi|ogv|m3u|pls)$'; then - detach $prefix mpv "$t" + if regeximatch "$t" '^gophers://'; then + $prefix $fetcher "$t" | mpv - + else + detach $prefix mpv "$t" + fi elif regeximatch "$t" '\.(mp3|ogg|m3u|wav|opus)$'; then $prefix mplayer "$(fetch "$t")" elif regeximatch "$t" '\.(png|jpg|jpeg|tif|bmp|gif)$'; then @@ -240,6 +248,8 @@ handle_url() { termopen $PAGER "$f" elif regeximatch "$t" '^gopher://'; then termopen $prefix sacc "$t" + elif regeximatch "$t" '^gophers://'; then + termopen $prefix plumb "$(fetch "$t")" elif regeximatch "$t" '[A-z]\.[0-9]$'; then if [ -z "$TERM" ]; then detach $TERMINAL mandoc -l "$(fetch "$t")"