t* dwm + patches URI git clone git://git.codevoid.de/dwm-sdk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit d2fcf19029e2233002047b53ff2a6ab2b50c7352 DIR parent 65cf11f55f5b64dad6cc15f17c7fd09177100d0b URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Sat, 27 Apr 2019 08:17:55 +0200 Add image and video preview scripts Diffstat: A scripts/preview | 18 ++++++++++++++++++ A scripts/youtube | 6 ++++++ 2 files changed, 24 insertions(+), 0 deletions(-) --- DIR diff --git a/scripts/preview b/scripts/preview t@@ -0,0 +1,18 @@ +#!/bin/sh +printf "Preview!\n" | $HOME/.bin/osd_pipe.sh +DIR="$HOME/.cache/preview" +URL="$(xclip -rmlastnl -o)" +TMP="$DIR/$(sha256 -qs "$URL")" +mkdir -p "$DIR" + +if [[ -f "$TMP" ]]; then + printf "Serving file from cache.\n" + pqiv -i "$TMP" +else + printf "Downloading...\n" + curl -s "$URL" > "$TMP" && \ + pqiv -i "$TMP" + if [ $? -ne 0 ]; then + printf "Preview: failed\n" | $HOME/.bin/osd_pipe.sh + fi +fi DIR diff --git a/scripts/youtube b/scripts/youtube t@@ -0,0 +1,6 @@ +#!/bin/sh +printf "Youtube!\n" | $HOME/.bin/osd_pipe.sh +mpv "$(xclip -rmlastnl -o)" +if [ $? -ne 0 ]; then + printf "Youtube: failed\n" | $HOME/.bin/osd_pipe.sh +fi