linkhandler.sh (1057B)
1 #!/bin/sh 2 3 # Feed script a url or file location. 4 # If an image, it will view in nsxiv, 5 # if a video or gif, it will view in mpv 6 # if a music file or pdf, it will download, 7 # otherwise it opens link in browser. 8 9 if [ -z "$1" ]; then 10 url="$(xclip -o)" 11 else 12 url="$1" 13 fi 14 15 case "$url" in 16 *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*) 17 setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;; 18 *png|*jpg|*jpe|*jpeg|*gif|*webp) 19 curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && nsxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; 20 *pdf|*cbz|*cbr) 21 curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; 22 *mp3|*flac|*opus|*mp3?source*) 23 qndl "$url" 'curl -LO' >/dev/null 2>&1 ;; 24 *) 25 [ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1 26 esac