From a77071a22f92e95d4e7fc5e88029fc1b76c460f4 Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Tue, 2 Apr 2019 19:02:28 +0200 Subject: [PATCH] replaced urlview with urlscan --- urlscan/.scripts/linkhandler.sh | 35 +++++++++++++++++++++++++++++++++ urlview/.urlview | 2 -- urlview/bin/linkhandler.sh | 20 ------------------- 3 files changed, 35 insertions(+), 22 deletions(-) create mode 100755 urlscan/.scripts/linkhandler.sh delete mode 100644 urlview/.urlview delete mode 100755 urlview/bin/linkhandler.sh diff --git a/urlscan/.scripts/linkhandler.sh b/urlscan/.scripts/linkhandler.sh new file mode 100755 index 0000000..4298819 --- /dev/null +++ b/urlscan/.scripts/linkhandler.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# Feed script a url or file location. +# If an image, it will view in sxiv, +# if a video or gif, it will view in mpv +# if a music file or pdf, it will download, +# otherwise it opens link in browser. + +# Set default browser + if [ -e "/usr/bin/firefox" ] +then + export BROWSER="firefox" +elif [ -e "/usr/bin/iceweasel" ] +then + export BROWSER="iceweasel" +fi + +# Set default terminal +export TERMINAL="st" + +case "$1" in + *mkv|*webm|*mp4|*youtube.com*|*youtu.be*|*hooktube.com*|*bitchute.com*) + setsid mpv --input-ipc-server=/tmp/mpvsoc"$(date +%s)" -quiet "$1" >/dev/null 2>&1 & ;; + *png|*jpg|*jpe|*jpeg|*gif) + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source*) + setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;; + *) + if [ -f "$1" ]; + then + "$TERMINAL" -e "$EDITOR $1" + else + setsid "$BROWSER" "$1" >/dev/null 2>&1 & + fi ;; +esac diff --git a/urlview/.urlview b/urlview/.urlview deleted file mode 100644 index 372640a..0000000 --- a/urlview/.urlview +++ /dev/null @@ -1,2 +0,0 @@ -REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):] -COMMAND linkhandler.sh diff --git a/urlview/bin/linkhandler.sh b/urlview/bin/linkhandler.sh deleted file mode 100755 index 58470f5..0000000 --- a/urlview/bin/linkhandler.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# List of sites that will be opened in mpv. -vidsites="youtube.com" -ext="${1##*.}" -mpvFiles="mkv mp4 gif webm mp3 flac" -fehFiles="png jpg jpeg jpe" -wgetFiles="iso" - -if echo $fehFiles | grep -w $ext > /dev/null; then - feh "$1" >/dev/null & disown -elif echo $mpvFiles | grep -w $ext > /dev/null; then - mpv -quiet "$1" > /dev/null & disown -elif echo $wgetFiles | grep -w $ext > /dev/null; then - wget "$1" >/dev/null & disown -elif echo "$@" | grep "$vidsites">/dev/null; then - mpv -quiet "$1" > /dev/null & disown -else - firefox "$1" 2>/dev/null & disown -fi