Mime: Difference between revisions

From miki
Jump to navigation Jump to search
(Created page with "== Overview == Use <code>mimetype</code> to view the MIME type of a file <source lang="bash"> mimetype myfile.svg # myfile.svg: image/svg+xml </source> To change default appl...")
 
 
Line 6: Line 6:
</source>
</source>


=== Using <code>see</code> ===
To change default application for a given MIME type:
To change default application used by <code>see</code> for a given MIME type:
* For user, edit {{file|~/.mailcap}}:
* For user, edit {{file|~/.mailcap}}:
<source lang="text">
<source lang="text">
Line 22: Line 23:
man mimeopen # Apparently not same as "see"
man mimeopen # Apparently not same as "see"
man see
man see
</source>

=== Using <code>xdg-open</code> ===
<code>xdg-open</code> is used by desktop application, but also ''Midnight Commander'' (<code>mc</code>).

To query default application:
<source lang="bash">
xdg-mime query filetype myfile.svg
# image/svg+xml
xdg-mime query default image/svg+xml
# eog.desktop
</source>

To change the default:
<source lang="bash">
xdg-mime default chromium.desktop image/svg+xml
xdg-mime query default image/svg+xml
# chromium.desktop
</source>
</source>



Latest revision as of 18:07, 17 May 2019

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