Ok, so here's what I want to do:

I have a file with a specific extension (*.ipynb) that I want to connect with a specific program. Ubuntu however thinks it is a text/plain file.

There are a lot of questions about this topic here on AskUbuntu, but non of them worked. I also tried to follow the instructions that are given here: https://help.ubuntu.com/community/AddingMimeTypes - did not work.

Since this is definitely a problem a lot of users experience, can anyone post an answer that explains how to do this?


1 Answer 1


This worked for me as well! Figured I might as well post it as an answer - https://wiki.archlinux.org/index.php/Default_Applications#Custom_file_associations :

Custom file associations

The following method creates a custom mime type and file association manually. This is useful if your desktop does not have a mime type/file association editor installed. In this example, a fictional multimedia application 'foobar' will be associated with all *.foo files. This will only affect the current user.

First, create the file ~/.local/share/mime/packages/application-x-foobar.xml:

mkdir -p ~/.local/share/mime/packages
cd ~/.local/share/mime/packages
touch application-x-foobar.xml

Then edit ~/.local/share/mime/packages/application-x-foobar.xml and add this text:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-foobar">
        <comment>foo file</comment>
        <icon name="application-x-foobar"/>
        <glob pattern="*.foo"/>

Note that you can use any icon, including one for another application.

Next, edit or create the file ~/.local/share/applications/foobar.desktop to contain something like:

[Desktop Entry]

Note that Categories should be set appropriately for the application type (in this example, a multimedia app).

Now update the applications and mime database with:

update-desktop-database ~/.local/share/applications
update-mime-database    ~/.local/share/mime

Programs that use mime types, such as file managers, should now open *.foo files with foobar. (You may need to restart your file manager to see the change.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.