Mime

From miki
Revision as of 18:07, 17 May 2019 by Mip (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Use mimetype to view the MIME type of a file

mimetype myfile.svg
# myfile.svg: image/svg+xml

Using see

To change default application used by see for a given MIME type:

  • For user, edit ~/.mailcap:
image/svg+xml; /usr/bin/chromium %s; test=test -n "$DISPLAY"
  • System-wide, edit /etc/mailcap.order, then run sudo update-mime:
evince:application/pdf

Other relevant information:

man mimetype
man mimeview
man mimeopen           # Apparently not same as "see"
man see

Using xdg-open

xdg-open is used by desktop application, but also Midnight Commander (mc).

To query default application:

xdg-mime query filetype myfile.svg
# image/svg+xml
xdg-mime query default image/svg+xml
# eog.desktop

To change the default:

xdg-mime default chromium.desktop image/svg+xml
xdg-mime query default image/svg+xml
# chromium.desktop

Troubleshooting

Open PDF files with Evince (instead of Gimp)

On recent Debian / Ubuntu releases, PDF files are opened by Gimp instead of the PDF viewer, like Evince.

To fix the issue system-wide:

  • Create a MIME entry for evince [1]:
echo 'application/pdf; evince %s; test=test -n "$DISPLAY"' | sudo tee /usr/lib/mime/packages/evince
  • Change MIME order in /etc/mailcap.order:
echo 'evince:application/pdf'| sudo tee -a /etc/mailcap.order
sudo update-mime