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

Asked by Skyler Lehmkuhl

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:
Last query:
Last reply:

This question was reopened

Revision history for this message
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.

Revision history for this message
Skyler Lehmkuhl (skykooler) said :
#2

Thanks Michael Terry, that solved my question.

Revision history for this message
Skyler Lehmkuhl (skykooler) said :
#3

Is there a way to install mime icons as well?

Revision history for this message
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']),

Revision history for this message
Skyler Lehmkuhl (skykooler) said :
#5

Thanks Michael Terry, that solved my question.