summaryrefslogtreecommitdiff
path: root/bin/guiscripts
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-03 19:53:53 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-03 19:53:53 +0100
commit2c66b7244c81f163d450a013c1778b728e206b96 (patch)
tree15f886c4ee806f3351d40bdf4350aa30ca63c4eb /bin/guiscripts
parent3a802d7f045c5ceebeeeb14110f22911e02b5938 (diff)
added linkhandler and sturl!
Diffstat (limited to 'bin/guiscripts')
-rwxr-xr-xbin/guiscripts/linkhandler27
-rwxr-xr-xbin/guiscripts/sturl4
2 files changed, 31 insertions, 0 deletions
diff --git a/bin/guiscripts/linkhandler b/bin/guiscripts/linkhandler
new file mode 100755
index 0000000..a3a6b64
--- /dev/null
+++ b/bin/guiscripts/linkhandler
@@ -0,0 +1,27 @@
+#!/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.
+
+if [ -z "$1" ]; then
+ url="$(xclip -sel c -o)"
+else
+ url="$1"
+fi
+dunstify "linkhandler" "<b>handling</b> $url"
+
+case "$url" in
+ *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
+ setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;;
+ *png|*jpg|*jpe|*jpeg|*gif)
+ curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
+ *pdf|*cbz|*cbr)
+ curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && evince "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
+ *mp3|*flac|*opus|*mp3?source*)
+ qndl "$url" 'curl -LO' >/dev/null 2>&1 ;;
+ *)
+ [ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1
+esac
diff --git a/bin/guiscripts/sturl b/bin/guiscripts/sturl
new file mode 100755
index 0000000..f7a3956
--- /dev/null
+++ b/bin/guiscripts/sturl
@@ -0,0 +1,4 @@
+#!/bin/sh
+regex='\(ipfs:\|ipns:\|magnet:\|mailto:\|gemini:\|gopher:\|https:\|http:\|news:\|file:\|git:\|ssh:\|ftp:\)[^\<>"{-}\^`]\+'
+url="$(grep "$regex" | sort | uniq | dmenu -g 1 -l 10 -x -c)"
+linkhandler $url