plumber

simple plumber tool
git clone https://git.parazyd.org/plumber
Log | Files | Refs

commit 441dba74c01bfbfcccbdac039a7e178311e97200
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  7 Feb 2019 22:31:28 +0100

Initial commit.

Diffstat:
AMakefile | 15+++++++++++++++
Ap | 46++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,15 @@ +.POSIX: + +PREFIX = /usr/local + +BIN = p + +all: + @echo Run "make install" to install to $(DESTDIR)$(PREFIX) + +install: + cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BIN) + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN) diff --git a/p b/p @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Copy me if you can. +# By parazyd +# + +clip="$(xclip -o)" + +[ -n "$clip" ] || { + echo "plubmer: Nothing to plumb." >&2 + exit 1 +} + +termcmd="st -e" + +case "$clip" in + + gopher://*/I/*) + curl "$clip" | feh - + ;; + + gopher://*) + $termcmd sacc "$clip" + ;; + + https://www.youtube.com/*|ytdl://) + mpv "$clip" + ;; + + *.jpg|*.png|*.JPG|*.JPEG|*.PNG) + feh "$clip" + ;; + + *.mp4|*.webm) + mpv "$clip" + ;; + + *.gif|*.GIF) + mpv --loop "$clip" + ;; + + *) + printf "plumber: no plumber for %s\n" "$clip" >&2 + exit 1 + ;; +esac