nautilus file-manager nemo – How to Prevent Program from Taking Over File Manager

file-managernautilusnemo

The problem described below appears sometimes when a folder is opened from context menu with an option similar to "Open with" – "Other application"

enter image description here

What happens is that the program selected in this way (and which after that is already available under "Open with" context menu for selected folder) takes over the file manager function in different other applications, like Firefox, Chromium, uGet, Calibre, etc, which have options similar to 'Open containing folder'.

enter image description here


enter image description here


enter image description here

Not all programs selected in this way trigger the problem (from what I've seen, namely qmmp, Decibel audio player, Easytag, Atom text editor are some of those). – Also, not all applications mentioned as affected by the problem (Firefox, etc) are to be affected at the same time. In the past I have often seen this in Firefox, but last time Firefox was not affected but uGet and Calibre were.)

This problem is frequently reported on Linux sites like this, for example:

"Open Containing Folder" not using the file manager

Set standard file browser for "open containing folder"

Stop folders opening with different application than the file manager

“Open containing folder” in Firefox does not use my default file manager

What happens is that the program in question becomes the first to appear in /usr/share/applications/mimeinfo.cache after inode/directory=.

This doesn't cause automatically the problem reported in the linked questions, I have a system (elementaryOS Loki) where the file manager is listed there last without any problems, but in another Linux (Manjaro) the file manager has to be listed first, like (for Nemo) inode/directory=nemo.desktop;decibel-audio-player.desktop;au‌​dacious.desktop;.

But how to open a folder in a such program without this kind of conflicts with the file manager?


I'm creating this question in order to provide the answer.


UPDATE:

As indicated in a comment by don_crissti under my initial answer: if the problem is triggered automatically after installing a certain program (in my case Decibel), it will re-appear even after correcting the file /usr/share/applications/mimeinfo.cache when a new installation or an update by the command update-desktop-database. (I will add te suggested solution to the answer too.)

Best Answer

The idea is to already have the needed programs in the 'Open with' context-menu for a selected folder without the need to select "Other application".

Editing the line inode/directory= in /usr/share/applications/mimeinfo.cache is not useful because, as indicated in a comment by don_crissti, the problem re-appears after an update or a program install because of the command update-desktop-database.

In fact only some programs will take over the file manager role as indicated by the question, but those that do will in some cases take over directly, simply after their installation, and will do again after update-desktop-database.

As suggested here by the aforementioned user, you need to edit ~/.local/share/applications/mimeapps.list like:

[Default Applications]
inode/directory==nemo.desktop;audacious.desktop;deadbeef.desktop;vlc.desktop

In another system (Cinnamon Manjaro, where there is no mimeapps.list in usr/share/applications, only mimeinfo.cache and seems non-freedesktop-complient) the file to use is ~/.local/share/applications/mimeinfo.cache with a content like

[MIME Cache]
inode/directory==nemo.desktop;audacious.desktop;deadbeef.desktop;vlc.desktop

It is essential to put the file manager first and then the programs to add to the 'open with' context menu.

For example, the above will give

enter image description here

Related Question