Linux – Clean way to run proper file manager from Firefox on Linux

cinnamond-busfirefoxkdelinux

As many of mans known, currently solution with defaults.conf and mimetypes.cache does not work.

Firefox currently uses D-bus to activate service org.freedesktop.FileManager1 to handle "Open containing folder" action and so on.

In case, when many service files installed (nemo and dolphin, for example) and no daemon running (dolphin --daemon or /usr/bin/nemo --no-default-window) there is no clean way to select preferred file manager.

On my system looks like selected first service file sorted in alphabetical order. So, on KDE system Firefox handles folders via Nemo.

I see currently at least two solutions, both seems as hack:

  1. make a symlink:

    ln -s /usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service /usr/share/dbus-1/services/00_preferred_org.freedesktop.FileManager1.service
    

    (don't forget to kill currently running file manager daemons or relogin session)

  2. Early pre-run needed org.freedesktop.FileManager1 handler. Like dolphin --daemon in ~/.profile under proper conditions.

It there more clean way?

PS try to execute file manager without Firefox:

dbus-send --session \
          --print-reply \
          --dest=org.freedesktop.FileManager1 \
          /org/freedesktop/FileManager1 \
          org.freedesktop.FileManager1.ShowFolders \
              array:string:"file:/" string:""

Best Answer

A cleaner way exists and it is similar to your first solution. Instead of mucking around in the system services folder, you can create your symlink in ~/.local/share/dbus-1/services/.

According to the dbus docs, dbus will look in $XDG_DATA_HOME/dbus-1/services (among others) for any service files and load them. Although the docs does not specify the order in which the folders are searched, I just tried this on my machine and it worked in finding the filemanager service I wanted to use.


In my case, I wanted to use nautilus as the default file manager in xfce instead of thunar, so I used this command to make it work:

ln -s /usr/share/dbus-1/services/org.freedesktop.FileManager1.service ~/.local/share/dbus-1/services/org.freedesktop.FileManager1.service

Other sources:

https://polywogsys.livejournal.com/309405.html

Related Question