Results 1 to 5 of 5

Thread: Faulty MIME detection

  1. #1
    Join Date
    Sep 2006
    Location
    Dresden / Germany
    Beans
    41
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Faulty MIME detection

    Hi,

    I'm working with MEI files, which are XML files. Unfortunately, they are detected as HTML. My problem: I'd rather have them open in the XML editor by default, and HTML files in the browser.

    The smallest "legal" MEI file looks like
    Code:
    <?xml version="1.0"?>
    <mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="2012">
      <meiHead>
        <fileDesc>
          <titleStmt>
            <title/>
          </titleStmt>
          <pubStmt/>
        </fileDesc>
      </meiHead>
      <music/>
    </mei>
    xdg-mime tells me for this file:
    Code:
    $ xdg-mime query filetype mimeTest.mei 
    text/html
    My suspicion was that it might see the <title/> tag and for some strange reason think "ah, I know that, that's HTML". But for
    Code:
    <?xml version="1.0"?>
    <mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="2012">
      <meiHead>
        <fileDesc>
          <titleStmt/>
          <pubStmt/>
        </fileDesc>
      </meiHead>
      <music/>
    </mei>
    it still says
    Code:
    $ xdg-mime query filetype mimeTest.mei 
    text/html
    Only if I remove the <titleStmt/> entirely, it gives me
    Code:
    $ xdg-mime query filetype mimeTest.mei 
    application/xml
    As /etc/mime.types says:
    Users can add their own types if they wish by creating a ".mime.types" file in their home directory.
    I created ~/.mime.types with content
    Code:
    application/xml			mei
    But that didn't change anything.

    Can anyone give me some advice on this?

  2. #2
    Join Date
    Oct 2008
    Location
    Ottawa, Canada
    Beans
    813
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: Faulty MIME detection

    First install package assogiate which provides the File Types Editor app (very handy).

    Create a new type application/mei with Description 'MEI file'
    In the Related types tab, add a parent type: application/xml
    In the Filenames add *.mei
    That's it. Now any file with .mei suffix will open with your XML editor and be called MEI file.
    You can also experiment with detection by file contents if you want Ubuntu to find MEI files that don't have the .mei suffix.
    The editor also allows your to specify a default icon so go ahead and choose your favorite music icon.

    Cheers!
    Last edited by LewisTM; March 22nd, 2012 at 06:49 PM.
    husband@wife$ make sandwich
    Permission denied
    husband@wife$ sudo make sandwich

  3. #3
    Join Date
    Sep 2006
    Location
    Dresden / Germany
    Beans
    41
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Faulty MIME detection

    Thanks for the hint. I added *.mei to the XML extensions with assogiate, no problems any longer.

    The curious Linux user inside me is only wondering how this could have been done without dedicated software.

  4. #4
    Join Date
    Oct 2008
    Location
    Ottawa, Canada
    Beans
    813
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: Faulty MIME detection

    If you just wanted to add extensions (not create new types or change icons) I think you could have edited file ~/.local/share/mime/application/xml.xml
    Or system-wide in /usr/share/mime/application/xml.xml
    then
    Code:
    update-mime-database ~/.local/share/mime
    husband@wife$ make sandwich
    Permission denied
    husband@wife$ sudo make sandwich

  5. #5
    Join Date
    Sep 2006
    Location
    Dresden / Germany
    Beans
    41
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Faulty MIME detection

    I think I found some background info on gnome.org. Thanks again.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •