How to configure Linux to open files by extension?

The answer is simple but can't be guessed:

  1. Create a file named vnc-mime.xml (whatever name, but must obey some patern)
  2. Inside the file:

    <?xml version="1.0"?>  
    <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>  
        <mime-type type="application/extension-vnc">  
            <comment>.vnc file</comment>  
            <glob pattern="*.vnc"/>  
        </mime-type>  
    </mime-info>  
    
  3. Run "xdg-mime install vnc-mime.xml" as the local user. (or as root for the settings to be system-wide? Not tested)
  4. The mime type is now registered. Use your favorite file manager to select the program you want to run (with "Open as...")