[Linux] Register an undefined mime type and associate it with an application


An application called Qiita saves a project file called xxx.qiita.

However, the extension * .qiita is not registered and is not associated with Qiita. Set the file * .qiita to open with Qiita. Screenshot from 2020-03-25 00-35-09.png

Check the extension

First, make sure that the extension is not registered with the mimetype command.

$ mimetype article.qiita 
article.qiita: application/gzip

If it is not registered, it will be recognized as text / plain or ╩╗application / gzip`.

Define extension

$ sudo vi /usr/share/mime/packages/freedesktop.org.xml

Write xml while looking at the surrounding items. Comments are probably appropriate and okay.

  <mime-type type="application/qiita">
    <comment>Qiita file</comment>
    <comment xml:lang="ja">Qiita file</comment>
    <expanded-acronym>Qiita file</expanded-acronym>
    <glob pattern="*.qiita"/>

Update mime database.

$ sudo update-mime-database /usr/share/mime


$ mimetype article.qiita 
article.qiita: application/qiita

Associate the extension with the application

The app "Qiita" is compatible with "application / qiita", so make the settings.

Add to MimeType of the corresponding desktop file. If not, add a line.

$ sudo vi /usr/share/applications/qiita.desktop


$ update-desktop-database

You should be able to open the * .qiita file with Qiita.

Recommended Posts

[Linux] Register an undefined mime type and associate it with an application
Associate Python Enum with a function and make it Callable
Explanation of creating an application for displaying images and drawing with Python