How to run xdg-mime during the installation of a quickly-created package?

Asked by Skyler Lehmkuhl on 2011-03-26

I have written an application which uses a custom filetype. I know I can use the xdg-mime command in terminal to add this to the system mime types. How do I run this during installation? Is there somewhere in the setup.py that I can run system commands?

Question information

Language:
English Edit question
Status:
Solved
For:
Quickly Edit question
Assignee:
No assignee Edit question
Solved by:
Michael Terry
Solved:
2011-03-31
Last query:
2011-03-31
Last reply:
2011-03-31

This question was reopened

Michael Terry (mterry) said : #1

You should just have to put the file in /usr/share/mime/packages like so:

setup(...,
      data_files=[('/usr/share/mime/packages', ['custom-mime.xml']),
      )

When the .deb file is actually installed on a system, dpkg will update the mimetype database.

Skyler Lehmkuhl (skykooler) said : #2

Thanks Michael Terry, that solved my question.

Skyler Lehmkuhl (skykooler) said : #3

Is there a way to install mime icons as well?

Best Michael Terry (mterry) said : #4

You install those like normal icons, under the mimetypes directory in the hicolor icon theme. For example, if you wanted to add an icon for the "application/x-note" mimetype (this is a real example from tomboy):

/usr/share/icons/hicolor/16x16/mimetypes/application-x-note.png
/usr/share/icons/hicolor/22x22/mimetypes/application-x-note.png
/usr/share/icons/hicolor/48x48/mimetypes/application-x-note.png

Obviously, you don't need all the sizes, you can get by with just one. But you get the idea.

So in terms of setup.py, you can install those the same way:

      data_files=[('/usr/share/icons/hicolor/22x22/mimetypes', ['data/icons/22/application-x-note.png']),

Skyler Lehmkuhl (skykooler) said : #5

Thanks Michael Terry, that solved my question.