Advertisement
Guest User

List MIME types supported by llppac

a guest
Aug 13th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.41 KB | None | 0 0
  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" ";"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement