commit d2c86fedfba9071c1484ffb6c924f98fddb90da6
parent 015a0d7576af65822b35b0deeb1f7d33a9b9d5ea
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 5 Feb 2020 19:13:45 +0100
Handle images and video by downloading to temporary file
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/.local/bin/plumb b/.local/bin/plumb
@@ -31,16 +31,16 @@ detach() {
nohup "$@" >/dev/null 2>&1 &
}
-fetchtmp() {
+fetch() {
+ _o="$(mktemp)"
if type -v hurl >/dev/null 2>&1; then
- # TODO
- return 0
+ hurl "$1" > "$_o"
elif type -v curl >/dev/null 2>&1; then
- # TODO
- return 0
+ curl -L "$1" > "$_o"
else
die 'could not find hurl or curl'
fi
+ printf '%s' "$_o"
}
handle_target() {
@@ -85,13 +85,13 @@ handle_target() {
*.mp4|*.mkv|*.webm|*.ogv|*.avi|*.ogg|*.ogv|*.gifv)
detach mpv "$1";;
*.png|*.jpg|*.jpeg|*.tif|*.bmp)
- ;;
+ sxiv "$(fetch "$1")";;
*.pdf|*.ps|*.epub|*.djvu)
- ;;
+ zathura "$(fetch "$1")";;
*youtube.com*|*youtu.be*)
cd ~/tmp && detach youtube-dl "$1";;
*smbc-comics.com*|*xkcd.com*|*jspowerhour.com*)
- cd ~/tmp && detach comic "$1";;
+ cd /tmp && detach comic "$1";;
10.[0-9]*\/*)
detach $BROWSER "https://doi.org/${1}" ;;
gopher://*)