Please don't mark it as duplicated before reading my question. I know that there already are those questions, but the existing answer did not work as expected, and that is why I am asking this question.

Existing answers say that the way to set the default file manager is xdg-mime default <app name> inode/directory, and the way to locate a file with the default file manager is dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"<path>" string:"".

But when I tested this on a few Arch-based distributions including Arch with Gnome, the dbus-send command did not always open the file manager that the xdg-mime query default indicates, after installing Nemo file manager (Gnome's default file manager is Gnome Files). Whilst xdg-mime query default inode/directory outputs nemo.desktop, the dbus-send... command above opened Gnome Files, and when the former outputs "org.gnome.Nautilus.desktop", the latter opened Nemo. (This is when there is no running file manager. If there already is an instance of a file manager, dbus-send command seem to use that file manager.)

Is the dbus-send command above is the right command to "locate a file with the default file manager"? Whilst the dbus-send above command did not work as expected, JetBrain's IDE's like Android Studio or IntellJ correctly located the file with the default file manager, when I right-clicked a file, and then click "Open in", and then the file manager's name. I thought of looking into their source code, but those are huge applications and trying to search their source code returned no result (I used keywords like "open in" or "file manager").

1 Answer 1


Those two configurations have nothing to do with each other, as the system doesn't really have a unified concept of "default file manager". xdg-mime only changes MIME type associations but has absolutely no effect on what service gets activated when a program attempts to talk to org.freedesktop.FileManager1 via D-Bus.

(It's a bit like how .html files and http:// URLs can be associated with different programs.)

For legacy reasons, dbus-daemon allows multiple .service files to claim that they provide the same service name. (This only matters when activating a service that's not yet running; activation isn't used if the name is already claimed by an already running process.)

The first step might be to figure out which D-Bus .service files provide the name:

$ grep -rl Name=org.freedesktop.FileManager1 /usr/share/dbus-1/services

(Don't mind that the file names do not match the service name they apparently provide.)

Then override the unwanted services via ~/.local/share/dbus-1:

$ mkdir -p ~/.local/share/dbus-1/services
$ ln -s /dev/null ~/.local/share/dbus-1/services/org.xfce.Thunar.FileManager1.service
$ ln -s /dev/null ~/.local/share/dbus-1/services/org.kde.dolphin.FileManager1.service

The one named org.freedesktop.FileManager1.service actually happens to be Nautilus, so it can stay:

$ cat org.freedesktop.FileManager1.service 
[D-BUS Service]
Exec=/usr/bin/nautilus --gapplication-service

Verify whether it works:

$ urlencode() {
    echo -n "$1" | perl -pe's/[^\/A-Za-z0-9_.!~,=-]/sprintf"%%%02X",ord$&/gse'
$ uri="file://$(urlencode "$path")"
$ gdbus call -e -d org.freedesktop.FileManager1 \
                -o /org/freedesktop/FileManager1 \
                -m org.freedesktop.FileManager1.ShowItems \
                "['$uri']" \
  • I removed the two nemo....service files in the DBus service directory and then the same dbus-send command opened Gnome Files, instead of Nemo. To be sure, I put those service files back to the directory, and so far, the dbus-send command still opens Gnome files. This situation illustrates one of Linux's problems, that there is no central authority to make one standard... Oh well. Commented Apr 30, 2023 at 20:52
  • Funny, people usually complain about the opposite whenever someone tries to set a single standard. Commented Apr 30, 2023 at 23:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .