plumber (1409B)
1 #!/bin/sh 2 # 3 # Copy me if you can. 4 # By parazyd 5 # 6 7 if [ -n "$1" ]; then 8 clip="$1" 9 else 10 clip="$(xclip -o)" 11 fi 12 13 TERMCMD="${TERMCMD:-st -e}" 14 15 case "$clip" in 16 *.jpg|*.jpeg|*.JPG|*.JPEG|*.png|*.PNG|*.ico|*.ICO) 17 feh "$clip" & 18 ;; 19 20 *.mp4|*.MP4|*.webm|*.WEBM|*.mkv|*.MKV|*.avi|*.AVI|*.wav|*.WAV|\ 21 *.mp3|*.MP3) 22 mpv "$clip" & 23 ;; 24 25 *.txt|*.TXT|*.vtt|*.VTT|*.vt|*.VT) 26 case "$clip" in 27 gopher://*|gophers://*|http://*|https://*) 28 $TERMCMD sh -c "hurl '$clip' | less" & 29 ;; 30 *) 31 $TERMCMD less "$clip" & 32 ;; 33 esac 34 ;; 35 36 *.gif|*.GIF) 37 mpv --loop "$clip" & 38 ;; 39 40 *.svg|*.SVG) 41 case "$clip" in 42 gopher://*|gophers://*|http://*|https://*) 43 hurl "$clip" | convert svg:- png:- | feh - & 44 ;; 45 *) 46 convert svg:- png:- < "$clip" | feh - & 47 ;; 48 esac 49 ;; 50 51 gopher://*|gophers://*) 52 $TERMCMD sacc "$clip" & 53 ;; 54 55 http://*|https://*) 56 case "$clip" in 57 *www.reddit.com*) 58 clip="$(printf "%s" "$clip" | sed 's,www.reddit,old.reddit,')" 59 ff -new-tab "$clip" & 60 ;; 61 *twimg.com*|*.scontent*.fbcdn.net*) 62 feh "$clip" & 63 ;; 64 *youtube.com*|*youtu.be*|*vimeo.com*|*dailymotion.com*|*invidious.tube*|\ 65 *yewtu.be*) 66 mpv "$clip" & 67 ;; 68 *) 69 ff -new-tab "$clip" & 70 ;; 71 esac 72 ;; 73 74 ytdl://*) 75 mpv "$clip" & 76 ;; 77 78 ssh://*) 79 $TERMCMD ssh "$clip" & 80 ;; 81 82 magnet:*) 83 printf "%s" "$clip" | xclip -sel clipboard 84 ;; 85 86 "") 87 logger -s "plumber: nothing to plumb" 88 exit 1 89 ;; 90 91 *) 92 logger -s "plumber: no plumber for plumbed data" 93 exit 1 94 ;; 95 96 esac