dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

mario (1232B)


      1 #!/bin/sh
      2 # ┏┏┓┳━┓┳━┓o┏━┓
      3 # ┃┃┃┃━┫┃┳┛┃┃ ┃
      4 # ┛ ┇┛ ┇┇┗┛┇┛━┛
      5 # p l u m b e r
      6 
      7 url="$1"
      8 filetype=$(curl -Ls "${url}" | file - | awk '{print $2}')
      9 
     10 iso_type() {
     11 	_iso=$(curl -Ls "${url}" | file - | awk '{print $4}')
     12 	case ${_iso} in
     13 		MP4) /usr/bin/mpv "${url}" ;;
     14 		*) /usr/bin/notify-send -u 'normal' "mario: unknown iso type ${_iso}" ;;
     15 	esac
     16 }
     17 
     18 vimify() {
     19 	timestamp=$(date +%s)
     20 	curl -L -o /tmp/mario-${timestamp} "${1}"
     21 	LANG=en_US.UTF-8 urxvt -cd /home/pyratebeard -hold -e vim /tmp/mario-${timestamp}
     22 	rm -f /tmp/mario-${timestamp}
     23 }
     24 
     25 plumbit() {
     26 	case ${filetype} in
     27 		JPEG|PNG|GIF) /home/pyratebeard/bin/webimg "${url}" ;;
     28 		Audio|WebM) /usr/bin/mpv "${url}" ;;
     29 		POSIX) LANG=en_US.UTF-8 urxvt -hold -e curl -s ${url} ;;
     30 		ISO) iso_type ;;
     31 		HTML|XML) qutebrowser "${url}" ;;
     32 		Unicode|Bourne-Again|ASCII|C|Python) vimify "${url}" ;;
     33 		PDF) curl -L -o /tmp/mario.pdf "${url}" ; zathura /tmp/mario.pdf ; rm -f /tmp/mario.pdf ;;
     34 		*) /usr/bin/notify-send -u 'normal' "mario: unknown filetype ${filetype}" ;;
     35 	esac
     36 }
     37 
     38 vidreg="(youtu|watch?v=)"
     39 (([[ "${url}" =~ $vidreg ]] && mpv "${url}") || ([[ "${url}" == *"gallery"* ]] && qutebrowser "${url}")) || plumbit