dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

open.sh (1364B)


      1 #!/bin/sh -e
      2 #
      3 # open
      4 
      5 main() {
      6     if [ ${#} -eq 0 ]; then opt="$(tee -i)"
      7     else opt="${*}"
      8     fi
      9 
     10     case "${opt}" in
     11         # audio
     12         *.flac \
     13       | *.m4a  \
     14       | *.mp3  \
     15       | *.ogg  \
     16       | *.opus \
     17       | *.wav)
     18             mpv --no-video "${opt}"
     19         ;;
     20 
     21         # document
     22         *.djvu \
     23       | *.epub \
     24       | *.pdf)
     25             "${READER}" "${opt}"
     26         ;;
     27 
     28         # gif
     29         *.gif)
     30             mpv --loop "${opt}"
     31         ;;
     32 
     33         # image
     34         *.bmp  \
     35       | *.dib  \
     36       | *.ff   \
     37       | *.ico  \
     38       | *.iff  \
     39       | *.jfi  \
     40       | *.jfif \
     41       | *.jif  \
     42       | *.jpe  \
     43       | *.jpeg \
     44       | *.jpg  \
     45       | *.lbm  \
     46       | *.png  \
     47       | *.pnm  \
     48       | *.tga  \
     49       | *.tif  \
     50       | *.tiff \
     51       | *.webp \
     52       | *.xpm)
     53             "${IMG_VIEWER}" "${opt}"
     54         ;;
     55 
     56         # video
     57         *.avi \
     58       | *.mkv \
     59       | *.mp4 \
     60       | *.webm)
     61             mpv "${opt}"
     62         ;;
     63 
     64         # web/vector
     65         *.htm   \
     66       | *.html  \
     67       | *.php   \
     68       | *.svg   \
     69       | *.xhtml)
     70             "${BROWSER}" "${opt}"
     71         ;;
     72 
     73         # torrent
     74         *.torrent)
     75             "${HOME}/.local/bin/bar/torr.sh" -a "${opt}"
     76         ;;
     77 
     78         # everything else
     79         *)
     80             exec "${EDITOR:-vi}" "${opt}" </dev/tty
     81         ;;
     82     esac
     83 }
     84 
     85 main "${@}"