dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

opener (1214B)


      1 #!/bin/sh
      2 # Opener: given a local file, decide which program to use to open it
      3 [ $# -gt 0 ] || { printf "File required in argument.\n" && exit 1; }
      4 case "$1" in
      5   # Handling links is another script's job
      6   *://*) linkhandler "$@";;
      7   *)
      8     case $(file --mime-type "$1" -bL) in
      9       text/*|application/json|inode/x-empty) { [ -n "$VIM_TERMINAL" ] && vimsend "$1"; } || ${EDITOR:-vim} "$1";;
     10       image/*) setsid -f sxiv -a "$@" 2>&1;;
     11       application/epub*) setsid -f ebook-viewer "$1" >/dev/null 2>&1;;
     12       application/pdf*) setsid -f /Applications/sioyek.app/Contents/MacOS/sioyek "$1" >/dev/null 2>&1;;
     13       application/x-sc|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) sc-im "$1";;
     14       video/*) mpvq "$@";;
     15       audio/*) mpv --no-audio-display --no-video --volume=50 "$1";;
     16       application/x-mach-binary) ;;
     17       application/octet-stream)
     18         case "$1" in
     19           *.mp3) mpv --no-audio-display --no-video --volume=50 "$1";;
     20           *.dmg) setsid -f open "$@" > /dev/null 2>&1;;
     21           *.webm|*.mp4|*.mkv) mpvq "$@";;
     22           *.docx) setsid -f soffice "$@" >/dev/null 2>&1;;
     23         esac
     24         ;;
     25       *) setsid -f open "$@" > /dev/null 2>&1;;
     26     esac;;
     27 esac