doc:appunti:linux:tux:mimetype
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:appunti:linux:tux:mimetype [2020/09/13 19:42] – [Application associated to a MIME Type] niccolo | doc:appunti:linux:tux:mimetype [2020/09/23 21:43] (current) – [MIME Type application/x-image-playlist] niccolo | ||
---|---|---|---|
Line 56: | Line 56: | ||
<code xml> | <code xml> | ||
+ | <!-- WARNING! This file is not optimal, see below for the final version. --> | ||
<?xml version=" | <?xml version=" | ||
< | < | ||
Line 153: | Line 154: | ||
===== Application associated to a MIME Type ===== | ===== Application associated to a MIME Type ===== | ||
- | To view if there is an application associated with our custom MIME Type, we can run the following command: | + | To view if there is an application associated with our custom MIME Type, we can run the following command. No result is returned, as we can expect: |
< | < | ||
Line 159: | Line 160: | ||
</ | </ | ||
- | No result | + | We check also the behaviour of the **Firefox** browser, we prepare an HTML file containing this (notice the **anchor** tag uses the **type** attribute to declare the proper MIME type): |
+ | |||
+ | <code xml> | ||
+ | <a href=" | ||
+ | </ | ||
+ | |||
+ | Once clicked the link, Firefox displays the //Open with...// dialog box suggesting to use **VLC** to open the **MPEG Audio URL**. | ||
+ | |||
+ | Now we prepare a file and save it as **/ | ||
+ | |||
+ | < | ||
+ | [Desktop Entry] | ||
+ | # The format of this file is specified at | ||
+ | # http:// | ||
+ | # The entries are in the order they are listed in version 1.0 | ||
+ | Type=Application | ||
+ | # This is the version of the spec for this file, not the application version. | ||
+ | Version=1.0 | ||
+ | Name=Photo-Reframe | ||
+ | GenericName=Image Viewer | ||
+ | Comment=Slideshow with on-the-fly image cropping | ||
+ | Icon=image | ||
+ | TryExec=photo-reframe | ||
+ | Exec=photo-reframe --fullscreen --play %f | ||
+ | Terminal=false | ||
+ | MimeType=application/ | ||
+ | # Category entry according to: | ||
+ | # http:// | ||
+ | Categories=Graphics; | ||
+ | </ | ||
+ | |||
+ | then we run the **update-desktop-database** over that directory (it will update the **mimeinfo.cache** file in the same directory): | ||
+ | |||
+ | < | ||
+ | update-desktop-database / | ||
+ | </ | ||
+ | |||
+ | Something good has happened; the system knows how to handle that MIME type: | ||
+ | |||
+ | < | ||
+ | xdg-mime query default application/ | ||
+ | photo-reframe.desktop | ||
+ | </ | ||
+ | |||
+ | After this step, Firefox suggests to use **Photo-Reframe (default)** to handle the link, you can check the box **Do this automatically for files like this from now on** and the associated application will be launched automatically whenever you will click over a link like this. Only after this association, | ||
+ | |||
+ | **NOTICE**: You may need to use **Shift-Click** to force the reloading of the link, otherwise Firefox may get the object from the cache, where the MIME type is cached too. | ||
+ | ===== Useless recipes ===== | ||
+ | |||
+ | There are many recipes to add a new MIME Type and an associated applications, | ||
+ | |||
+ | * / | ||
+ | * / | ||
+ | * $HOME/ | ||
+ | * $HOME/ | ||
+ | |||
+ | ===== Opening local files from an HTTP page ===== | ||
+ | |||
+ | For security reasons a web browser does not allow to open a **%%file:// | ||
+ | |||
+ | The link on the HTML page will look something like this: | ||
+ | |||
+ | <code html> | ||
+ | <a href=" | ||
+ | <img src=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | To bypass the Firefox restriction, | ||
+ | |||
+ | <code javascript> | ||
+ | user_pref(" | ||
+ | user_pref(" | ||
+ | user_pref(" | ||
+ | </ | ||
+ | |||
+ | |||
===== Web References ===== | ===== Web References ===== | ||
Line 166: | Line 244: | ||
* **[[https:// | * **[[https:// | ||
* **[[https:// | * **[[https:// | ||
+ | * **[[http:// |
doc/appunti/linux/tux/mimetype.1600018954.txt.gz · Last modified: 2020/09/13 19:42 by niccolo