Ubuntu – Files are opened by wrong applications if opened from a number of programs

file openingmime-typesUbuntu

History: I had problems with mime associations under Firefox. Firefox opened downloaded files with wrong programs. I deleted ~/.local/share/applications/mimeapps.list and now it works.

Now I noticed that the problem is transferred to Calibre and Chromium. For example, cbr files are opened with file-roller instead of evince, and directories are opened with Firefox!

Mime associations with the file browser (PCManFM) worked before and works now without problems. I'm under Lubuntu 13.10.

Best Answer

I had this problem with Calibre, and found a solution in this article by Jacek Bzdak. It's necessary to change the mimetype association for xdg-utils, which is the tool Calibre uses to open files:

  1. Get the mimetype of your problematic file, which can be done with one of xdg-utils commands, xdg-mime: xdg-mime query filetype <filename>

  2. Find the .desktop file for the application you want to use. In *buntu they should be in /usr/share/applications.

  3. Assign this file as a default: xdg-mime default myapp.desktop application/x-whatever (it doesn't need a absolute/relative path, just a .desktop filename)

(Unlikely to help you, two years later, but it was one of the top google results for me, so maybe someone else will find this useful.)

EDIT: fixed missing default keyword, thanks @Marco Sulla.