linkhandler (881B) - raw


      1 #!/bin/sh
      2 
      3 # Feed script a url or file location.
      4 # If an image, it will view in sxiv,
      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 no url given. Opens browser. For using script as $BROWSER.
     10 [ -z "$1" ] && { "$BROWSER"; exit; }
     11 
     12 case "$1" in
     13 	*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*video.twimg.com*)
     14 		mpv "$1" ;;
     15 		# mpv --no-config "$1" ;;
     16 		# setsid -f mpv --no-config "$1" ;;
     17 	*png|*jpg|*jpe|*jpeg|*gif|*.webp)
     18 		curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")"  >/dev/null 2>&1 & ;;
     19 	*mp3|*flac|*opus|*mp3?source*)
     20 		setsid -f tsp curl -LO "$1" >/dev/null 2>&1 ;;
     21 	*)
     22 		if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
     23 	else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;;
     24 esac