Ubuntu – How to teach firefox to open rar archives

archivefirefox

When I click on the .rar file in Firefox it offers either to open it with a default application or to save it to disk. However, the default app for .rar is set to gedit (?) So how do I change that, so that FF will offer to open .rar files with archive manager? I tried editing Preferences/Applications, but I need it to ask me first what to do and then open it ot save it. Thanks!

Best Answer

Success! I just got it to work for me. Here's how I did it:

Just like @jasmines suggested, you need to modify the mimeTypes.rdf file in your Firefox profile.

First go into your Firefox profile's directory. Using a terminal, cd ~/.mozilla/firefox/ then type ls you will see a directory with a name of random letters and numbers followed by .default (mine is 73mr2fae.default) this is your profile. Type cd [the name of the profile directory] replace the brackets with your profile name (you can use the Tab key to autocomplete once you have typed the first few letters).

First back up the mimeTypes.rdf file cp mimeTypes.rdf mimTypes.rdf.backup

Next open it for editing gedit mimeTypes.rd

Now paste in the following entry (make sure not to paste it within another entry, look for a line with a closing tag </RDF:Description> then hit the Return key to paste it on a new empty line after that closing tag):

  <RDF:Description RDF:about="urn:mimetype:application/x-rar-compressed"
                   NC:fileExtensions="rar"
                   NC:description="Rar archive"
                   NC:value="application/x-rar-compressed"
                   NC:editable="true">
    <NC:handlerProp RDF:resource="urn:mimetype:handler:application/x-rar-compressed"/>
  </RDF:Description>

Looks like Firefox will automatically alphabetize it later so as long as you don't put it inside another tag you should be set.

Next look for a section starting with <RDF: Seq... it will probably look like this:

  <RDF:Seq RDF:about="urn:mimetypes:root">
    <RDF:li RDF:resource="urn:mimetype:application/x-debian-package"/>
    <RDF:li RDF:resource="urn:mimetype:application/pdf"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-zip-compressed"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-msdownload"/>
    <RDF:li RDF:resource="urn:mimetype:application/zip"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-tar"/>
    <RDF:li RDF:resource="urn:mimetype:application/epub+zip"/>
  </RDF:Seq>

Add the line <RDF:li RDF:resource="urn:mimetype:application/x-rar-compressed"/> somewhere inside this tag, I don't think the order matters.

Here is what mine looks like afterwards:

  <RDF:Seq RDF:about="urn:mimetypes:root">
    <RDF:li RDF:resource="urn:mimetype:application/x-debian-package"/>
    <RDF:li RDF:resource="urn:mimetype:application/pdf"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-zip-compressed"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-msdownload"/>
    <RDF:li RDF:resource="urn:mimetype:application/zip"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-tar"/>
    <RDF:li RDF:resource="urn:mimetype:application/x-rar-compressed"/>
    <RDF:li RDF:resource="urn:mimetype:application/epub+zip"/>
  </RDF:Seq>

Save the file. Restart Firefox and download a .rar file (I used the test files here: http://www.maximumcompression.com/data/files/index.html).

The first time the dropdown box might look a little weird. But you can still click on it and select Archive Manager. Subsequent times it appears to remember this choice.

Hope this works for you!

Related Question