Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I edited my /usr/share/mime/packages/freedesktop.org.xml (with a text editor) to modify the file icon of application/x-7z-compressed mime type :

<mime-type type="application/x-7z-compressed">
  <generic-icon name="package-x-generic"/>

I would like to know if there is a tool to edit this file (or to change the icon of a mime type) instead of using a text editor ?

EDIT: My aim is to script my modifications of the freedesktop.org.xml file, so that an text editor is not appropriate.
I would like a command-line tool to edit the name attribut of the generic-icon tag of a chosen MIME type.

EDIT: As @Gilles pointed it to me, it should be better to modify the $XDG_DATA_HOME/mime/packages/Override.xml file instead of /usr/share/mime/packages/freedesktop.org.xml file. But this does not really change my question.

share|improve this question

/usr/share/mime/packages/freedesktop.org.xml is the Freedesktop MIME database. The web page lists many tools to query this database, and a few to modify it.

You should not be modifying this file manually: files under /usr but outside /usr/local are managed by your distribution's package manager, and your modifications would be overwritten on the next upgrade. Instead, write your own file in /usr/local/share/mime/packages, or somedir/packages where somedir is any other directory listed in $XDG_PATH. When you've modified the file, run update-mime-database /usr/local/share/mime/packages to update the cache (you need to run update-mime-database anyway, since applications read the binary cache and not the XML files).

share|improve this answer
Thanks for your answer, but you gave me a link to a list of programs that indeed query the mime database but which one allow to modify the file icon of a mime type? For instance MIME-editor allow to edit a bit the mime database but I didn't find how to modify the file icon of a mime type. – Nicolas Jan 14 '13 at 10:29

The point with XML is that you should be able to edit it manually, with an editor, and also view it (if necessary) without any surplus software.

This is one of the advantages of XML. Even the Lisp people want to take credit for XML, claiming its unrestricted way to markup data is a reinvention of the Lisp associative list (or alist) data structure.

But, although strictly speaking not necessary, you might want additional software in some cases. For example, in the Unix/Linux world, a common tool to do diagrams, state machine illustrations, and so on, is Dia. In Dia, when you draw diagrams, you use their GUI. But what you see is just a GFX representation of how your drawings are represented internally - as XML. This is a good example when it makes little sense using an editor editing and viewing XML: although it would be perfectly possible, it wouldn't be practical.

However, in your case, you are not drawing anything or doing anything that would motivate a GUI interface. So an editor is just fine. If you use Emacs, the .xml extension will automatically put you in the right mode if you open the file. An advanced editor will give you highlighting and indentation, as well as some more advanced features that you'll discover along the way.

share|improve this answer
I would like to have a tool to script the modifications I want to do, this way it will be easy to modify the freedesktop.org.xml file. While without an appropriate tool I have to edit the XML file with an XML library in a more powerful language than bash. – Nicolas Jan 13 '13 at 22:10
@Nicolas: I'm not following 100% - would you like a command (shortcut) that modifies the file? – Emanuel Berg Jan 13 '13 at 22:55
Absolutly, I need a program to modify the freedesktop.org.xml file. because I want to create an installation script that modifies the freedesktop.org.xml file and it would be easier for me to call a program that does the job instead of parsing and modifying myself the XML file. – Nicolas Jan 14 '13 at 10:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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