Ubuntu – Change file manager used by Firefox on Lubuntu

14.04filemanagerfirefoxlubuntu

I'm running Firefox 28 on Lubuntu 14.04 and I've noticed that when using "Open Containing Folder" it opens the folder in "Files" file manager instead of PCManFM. This is slightly annoying, so I've searched Tools > Options and about:config, but couldn't find anything related to the choice of the file manager.

I tried switching default manager to something else and switching it back, but it didn't work. Editing /usr/share/applications/defaults.list, /usr/share/applications/mimeinfo.cache, ~/.local/share/applications/defaults.list and ~/.local/share/applications/mimeapps.list also had no effect.

So, is there any reasonable way to change the file manager used by Firefox?

Btw. I'm aware of similar questions but this shouldn't be considered a duplicate, because it is for Lubuntu and general, not specific file manager (although I intend to use the answer specifically for PCManFM).

Best Answer

Inspired by Mozilla Firefox Bug 727422, comment 30, I found out that Firefox is currently (FF 36.0, Ubuntu 14.10 with LXDE) using the org.freedesktop.FileManager1-Interface on the Dbus session bus. As stated in the specification of this interface, Nautilus (also known as Files) is the only file manager that implements this interface. Therefore, Firefox will always choose Nautilus as file manager if it is installed.

So there are two possibilities to resolve this first problem:

  1. Uninstall Nautilus/Files
  2. Tamper with the org.freedesktop.FileManager1-Interface that Nautilus offers to disable this method of Firefox to open a file manager. Therefore, you could just delete /usr/share/dbus-1/services/org.freedesktop.FileManager1.service. But maybe, it is a better approach to use the proposed solution of https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/133133/comments/74 and create ~/.local/share/dbus-1/services/org.freedesktop.FileManager1.service and set its exec-line to /usr/bin/false (just copy /usr/share/dbus-1/services/org.freedesktop.FileManager1.service there and change it). This avoids deleting/editing a file created by your package manager and you do not need super user privileges. After having done so, you possibly need a restart.

As soon as Firefox can not use the Dbus-Interface anymore, it will fall back to a second way to figure out which file manager to start. This will lead to the second problem:

The default applications should be configured with several different mimeapps.list-files with different priorities. It seems to me that Firefox is correctly consulting the files ~/.config/mimeapps.list, ~/.local/share/applications/mimeapps.list and /usr/share/applications/mimeapps.list but not the deprecated defaults.list-file. So, you have to add the inode/directory=pcmanfm.desktop-entry to one of the three files mentioned above. This can also be done by calling gvfs-mime --set inode/directory pcmanfm.desktop or xdg-mime default pcmanfm.desktop inode/directory.

Lxde itself seems to use ~/.config/lxsession/LXDE/autostart to determine its default file manager. Therefore, you have to edit one of those files manually.

Related Question