Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

List MIME types supported by llppac

By: a guest on Aug 13th, 2013  |  syntax: Bash  |  size: 1.41 KB  |  views: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. # Prints MIME types supported by the llppac script
  3.  
  4. # Misc MIME types listed in the llppac script
  5. read -d '' miscMime <<"EOF"
  6. application/postscript
  7. application/pdf
  8. image/vnd.djvu
  9. text/html
  10. application/msword
  11. application/vnd.ms-powerpoint
  12. application/vnd.ms-excel
  13. image/svg+xml
  14. image/png
  15. image/jpeg
  16. application/x-dvi
  17. EOF
  18.  
  19. # MIME types of some office documents
  20. officeMimeOne=$(grep -E "application/vnd\.openxmlformats-officedocument\." /etc/mime.types | sed -r 's/\t+.+$//g')
  21. officeMimeTwo=$(grep -E "application/vnd\.oasis\.opendocument\." /etc/mime.types | sed -r 's/\t+.+$//g')
  22.  
  23. # lower case extensions of ImageMagick readable image formats
  24. # http://www.imagemagick.org/script/formats.php
  25. imExt=$(identify -list format | grep -E "^.{21}r" | grep -Eio "^ +[0-9a-z]+" | sed -r 's/ +//g' | tr '[:upper:]' '[:lower:]')
  26. # MIME types starting with "image/" collected from /etc/mime.types
  27. grep "image/" /etc/mime.types | sed -rn '/^[^\t]+\t+[^\t]+$/p' | sed -r 's/^([^\t]+)\t+([^\t]+)$/\2\t\1/' > image-mime.txt
  28. # MIME types of ImageMagick readable image formats starting with "image/"
  29. imMime=$(for i in $imExt; do sed -rn "/(^| )$i( |\t)/p" image-mime.txt | sed -r 's/.+\t//g'; done | sort -u)
  30. # cleanup
  31. rm -f image-mime.txt
  32.  
  33. # Print results separated with ";" (suitable in the MimeType field of .desktop files)
  34. echo -e "$miscMime\n$officeMimeOne\n$officeMimeTwo\n$imMime" | sort -u | tr "\n" ";"