humpty promotes - Linux - Lubuntu

Lubuntu linux Tips
Create a local file MIME type
Open the file you want with the App you want

Another horrible monstrosity of Linux (distros) is the use of Mime-Types.

Of all the hair pulling and head banging, Mime-types is near the top of the list when it comes to having to jump through hoops in order to do something basic.

Rewind back to 30 years ago. A simple beautiful idea of the ancient DOS file system that has survived
the tides of time is the notion of a postfixed 'extension'. i.e the 3 character code stuck after the 'dot' at the end of a filename e.g sample.doc. Modern OSs let you extend this 'file-type' to more than 3 chars, but this is beside the point.      This was and still is a simple solution to giving a file a 'type'.

And then somebody had the terrible idea of using internet MIME types for local files.
I guess this is fine if each file's type can be detected with 100% accuracy. But it can't. (whereareas the 3 char system CAN).
Even worse, to revert back to the solution of using the 'extension' can be a nightmare to implement if your OS is infested with MIME.

So here is one relatively painless way to do it using the brilliant SpaceFM file manager,     ( also compatible with PCmanFM)

SpaceFM has a built-in function to generate the xml file needed to create a new mime-type.

The following example is to open a config file for an app called Geany.
The file is plain text, but we don't want to open it with the default editor (Leafpad).
We want to open all ".geany" files with Geany. And leave all other text files to be opened with Leafpad.

To Apply Locally

1. First, modify the app's desktop entry..
file:     ~/.local/share/applications/geany.desktop
entry:    MimeType=text/geany;text/plain; .. .. ... etc

2. Make sure geany is associated with text files.
e.g ight-click sample.geany > Open >
should show 'Geany' under Open. If not, click Choose, and choose Geany, and set it as Default.

3.  Generate mime file: with SpaceFM,
right-click sample.geany > Open > right-click on the 'Geany' > text-plain.xml(*new)

    This creates ~/.local/share/mime/packages/text-plain.xml
Rename it to
file:     ~/.local/share/mime/packages/text-geany.xml

4.  Edit the generated mime file, change
<mime-type type='text/geany'>

    delete all unneccessary file types but do include

<glob pattern="*.geany"/>

    save the file.

5. Update the mime cache
> update-mime-database ~/.local/share/mime

6. close all instances of SpaceFM and restart it.

To Apply for All users

file:     /usr/share/applications/geany.desktop
entry: MimeType=text/geany;text/plain; .. .. ... etc

    generate, rename and edit the xml as above (as per local) and
    copy the local file from ~/.local/share/mime/packages/text-geany.xml
file:     /usr/share/mime/packages/text-geany.xml
and update the mime cache
command: update-mime-database /usr/share/mime

close all instances of SpaceFM and restart it.


Leading Cloud Surveillance, Recording and Storage service; IP camera live viewing

Leading Enterprise Cloud IT Service; cloud file server, FTP Hosting, Online Storage, Backup and Sharing

Powered by, a division of DriveHQ, the leading Cloud IT and Cloud Surveillance Service provider since 2003.