dotfiles

beau's configuration files
git clone https://git.beauhilton.com/dotfiles.git
Log | Files | Refs | README

linkhandler (870B)


      1 #!/usr/bin/env 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*)
     14 		setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;;
     15 	*png|*jpg|*jpe|*jpeg|*gif)
     16 		curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")"  >/dev/null 2>&1 & ;;
     17 	*mp3|*flac|*opus|*mp3?source*)
     18 		setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
     19 	*)
     20 		if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
     21 		else setsid "$BROWSER" "$1" >/dev/null 2>&1 & fi ;;
     22 esac