You probably already know that you can change the default application a specific file-type opens with, or specify one if there aren’t any listed, via Properties > Open With. But for those extensions that don’t have an actual mimetype defined, things can be problematic, as unknown file-types are seen as generic files, and classified according to what the system thinks they may be.
A good illustration of what this means is the .mht web archive format, which is actually a fancy version of a .html web page with pictures included (rather than separate in folders). Ubuntu does not know this extension by default, but determines it is a text file. So when you double-click it, it will open in the text editor, which will show you the text, but the pictures will be a huge mess of code.
And if you decide to get clever and make Opera or Firefox (with the unMHT plugin) the default for .mht files, it will backfire, as all your different types of text files will now open in your browser. Similarly, if you change the icon of .mht files to something more like a .html icon, the change will also happen to your text files of other extensions.
The way to get around all this is to create your own mimetype with assoGiate. You should be able to install it via Synaptic (if not, you may need more software sources), or you can go to the download page (note that the link for Ubuntu packages currently seems to be dead, but you can get the source code there, if you prefer compiling anyway; otherwise, you can get the i386/32-bit version and amd64/64-bit version here). Once installed, it will end up in Applications > System Tools > File Types Editor.
In assoGiate, use the New button to create a blank mimetype. You’ll see there are 5 tabs in the dialogue box that pops up, and generally you will only be putting information into General and Filenames. Some just require you to type data in an empty field (like the General tab), while others will require you to click an +Add button to do so (like the Filenames tab).
As an example of something basic you could do, I’ll use the .dmg file-type, which Mac OS users will know are program installers, like .exe files in Windows, and .deb files in Ubuntu. I download programs for Mac users, so I don’t actually need them opening in anything, but I just want the type registered, so it would be listed as “Mac OS Program Installer”, and have an easy-to-recognise icon.
Category: Multipurpose files
Description: Mac OS Program Installer
Use the Browse button [...] to select a Mac icon of your choice for the .dmg extension.
Next, you specify the file extension in the Filenames tab with the +Add button. Note that you can register more than one extension while you’re there.
Filename pattern: *.dmg
And that’s it. You’ve created a mimetype, even if it’s not that useful. But all you have to do is look through the various file-types, and you’ll soon see you can make your own by using existing mimetypes as examples. And you could do things like add another extension to an existing mimetype via the Filenames tab.
So we’ll use the example of an extension for text files called .Ubuntu. The scenario is that you’ve decided to separate your text files containing Ubuntu tips and tricks by renaming those with this extension. First go to Text and source code in the left pane of assoGiate, locate (Category) text (Name) plain, and double-click it to edit it. If the Description: is other than something like “Plain Text Document” (mine got hijacked by an Adobe product), you can change it there in the General tab.
Now all you need to do is go to the Filenames tab and +Add a new extension by entering *.Ubuntu. It will now be treated as a text file and open with the default text editor.
But if you want to have .Ubuntu files display a custom icon (like the Ubuntu logo) instead of the generic text icon, to have a descriptive name for that extension, and even have it open in another program, you’ll need to create a new mimetype for it instead of using the previous method. Click the New button and enter the data as follows:
Category: Multipurpose files
Description: Ubuntu Information Document
If you’re wondering whether you could have chosen Text and source code as the category, the answer is yes, but that the specified icon might not show up, and still be the generic text icon. At least putting it under Multipurpose files will ensure this is not the case.
► Related types:
Parent types: text/plain
Filename pattern: *.Ubuntu
And there you have it – you’ve just created your own mimetype for specific text files that will be easy to locate because of the icon you specified. If you’d now like to change the default application your .Ubuntu files open with, like have them open in Leafpad (which is more basic than the default Gedit, so loads a bit faster), check out how to do so here.
For a more advanced use of assoGiate, check out this post on registering MHT web archives. If you ever research a specific mimetype and are supplied with a bunch of technical data about it, you could probably use that in assoGiate to successfully register it as a file type in Ubuntu.
Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!