commit b831b8f86acb0c488dc9a3b43ef24fad38f5ea9b
parent ca400ea79cffa75149a38cf15bae2a095779cb2a
Author: parazyd <parazyd@dyne.org>
Date: Sun, 18 Apr 2021 11:00:52 +0200
Try some simplifications.
Diffstat:
M | plumber | | | 87 | ++++++++++++++++++++++++++++++++++--------------------------------------------- |
1 file changed, 37 insertions(+), 50 deletions(-)
diff --git a/plumber b/plumber
@@ -13,63 +13,64 @@ fi
TERMCMD="${TERMCMD:-st -e}"
case "$clip" in
-gopher://*|gophers://)
- if printf "%s" "$clip" | cut -d'/' -f3 | \
- xargs -i grep -q '{}' ~/.gophers-pins; then
- clip="$(printf "%s" "$clip" | sed 's,gopher://,gophers://,')"
- fi
-
+*.jpg|*.jpeg|*.JPG|*.JPEG|*.png|*.PNG|*.ico|*.ICO)
case "$clip" in
- *.jpg|*.jpeg|*.JPG|*.JPEG|*.png|*.PNG|*.ico|*.ICO)
+ gopher://*|gophers://*)
hurl "$clip" | feh - &
;;
- *.mp4|*.MP4|*.webm|*.WEBM|*.mkv|*.MKV|*.avi|*.AVI|*.wav|*.WAV)
- mpv "$clip" &
+ *)
+ feh "$clip" &
;;
- *.txt|*.TXT|*.vtt|*.VTT|*.vt|*.VT)
+ esac
+ ;;
+
+*.mp4|*.MP4|*.webm|*.WEBM|*.mkv|*.MKV|*.avi|*.AVI|*.wav|*.WAV|\
+*.mp3|*.MP3)
+ mpv "$clip" &
+ ;;
+
+*.txt|*.TXT|*.vtt|*.VTT|*.vt|*.VT)
+ case "$clip" in
+ gopher://*|gophers://*|http://*|https://*)
$TERMCMD sh -c "hurl '$clip' | less" &
;;
- *.gif|*.GIF)
- f="$(mktemp /tmp/XXXX.gif)"
- hurl "$clip" > "$f"
- sxiv -a "$f"
- rm -f "$f"
+ *)
+ $TERMCMD less "$clip" &
;;
- *.svg|*.SVG)
+ esac
+ ;;
+
+*.gif|*.GIF)
+ mpv --loop "$clip" &
+ ;;
+
+*.svg|*.SVG)
+ case "$clip" in
+ gopher://*|gophers://*|http://*|https://*)
hurl "$clip" | convert svg:- png:- | feh - &
;;
*)
- $TERMCMD sacc "$clip" &
+ convert svg:- png:- < "$clip" | feh - &
;;
esac
;;
+gopher://*|gophers://*)
+ $TERMCMD sacc "$clip" &
+ ;;
+
http://*|https://*)
case "$clip" in
*www.reddit.com*)
- l="$(printf "%s" "$clip" | sed 's/www.reddit/old.reddit/')"
- ff -new-tab "$l" &
+ clip="$(printf "%s" "$clip" | sed 's,www.reddit,old.reddit,')"
+ ff -new-tab "$clip" &
;;
- *.jpg|*.jpeg|*.JPG|*.JPEG|*.png|*.PNG|*.ico|*.ICO|\
- *twimg.com*|*scontent*.fbcdn.net/*)
+ *twimg.com*|*.scontent*.fbcdn.net*)
hurl "$clip" | feh - &
;;
- *.mp4|*.MP4|*.webm|*.WEBM|*.mkv|*.MKV|*.avi|*.AVI|*.wav|*.WAV|\
- *.mp3)
- mpv "$clip" &
- ;;
- *.gif|*.GIF)
- f="$(mktemp /tmp/XXXX.gif)"
- hurl "$clip" > "$f"
- sxiv -a "$f"
- rm -f "$f"
- ;;
*youtube.com*|*youtu.be*|*vimeo.com*|*dailymotion.com*|*invidious.tube*)
mpv "$clip" &
;;
- *.svg|*.SVG)
- hurl "$clip" | convert svg:- png:- | feh - &
- ;;
*)
ff -new-tab "$clip" &
;;
@@ -84,22 +85,6 @@ ssh://*)
$TERMCMD ssh "$clip" &
;;
-*.jpg|*.jpeg|*.JPG|*.JPEG|*.png|*.PNG)
- feh "$clip" &
- ;;
-
-*.mp4|*.MP4|*.webm|*.WEBM|*.mkv|*.MKV|*.avi|*.AVI|*.wav|*.WAV)
- mpv "$clip" &
- ;;
-
-*.gif|*.GIF)
- sxiv "$clip" &
- ;;
-
-*.svg|*.SVG)
- hurl "$clip" | convert svg:- png:- | feh - &
- ;;
-
magnet:*)
printf "%s" "$clip" | xclip -sel clipboard
;;
@@ -108,8 +93,10 @@ magnet:*)
logger -s "plumber: nothing to plumb"
exit 1
;;
+
*)
logger -s "plumber: no plumber for plumbed data"
exit 1
;;
+
esac