Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

xdg-openhack 905B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env sh
  2. #
  3. # pbrisbin 2013 - open files with the appropriate handler program.
  4. #
  5. ###
  6. read_mime() {
  7. local file="$1"
  8. xdg-mime query filetype "$file" 2>/dev/null | cut -d ';' -f 1
  9. }
  10. handle_archive() {
  11. local archive="$1" directory="${1}_extracted"
  12. mkdir -p "$directory" && cd "$directory" &&
  13. archive -x "$archive" && NOCD=1 exec urxvtc -cd "$directory"
  14. }
  15. [ $# -eq 0 ] && exit 1
  16. if [ ! -f "$1" ]; then
  17. # Assume non-files are URLs
  18. exec $BROWSER "$1"
  19. fi
  20. mimetype="$(read_mime "$1")" || mimetype='text/html'
  21. case "$mimetype" in
  22. text/html) $BROWSER "$1" ;;
  23. application/pdf) exec zathura "$1" ;;
  24. application/ogg) exec mplayer "$1" ;;
  25. audio/*|video/*) exec mplayer "$1" ;;
  26. image/*) exec mirage "$1" ;;
  27. text/*) exec urxvtc -e vim "$1" ;;
  28. application/x-gzip|application/x-rar-compressed|application/zip)
  29. handle_archive "$1"
  30. ;;
  31. esac