Skip to main content
added 398 characters in body
Source Link
grawity
  • 16.3k
  • 1
  • 34
  • 54

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
/usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service
/usr/share/dbus-1/services/org.xfce.Thunar.FileManager1.service
/usr/share/dbus-1/services/org.freedesktop.FileManager1.service

(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]
Name=org.freedesktop.FileManager1
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']" \
                "''"

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
/usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service
/usr/share/dbus-1/services/org.xfce.Thunar.FileManager1.service
/usr/share/dbus-1/services/org.freedesktop.FileManager1.service

(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]
Name=org.freedesktop.FileManager1
Exec=/usr/bin/nautilus --gapplication-service

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
/usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service
/usr/share/dbus-1/services/org.xfce.Thunar.FileManager1.service
/usr/share/dbus-1/services/org.freedesktop.FileManager1.service

(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]
Name=org.freedesktop.FileManager1
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']" \
                "''"
Source Link
grawity
  • 16.3k
  • 1
  • 34
  • 54

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
/usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service
/usr/share/dbus-1/services/org.xfce.Thunar.FileManager1.service
/usr/share/dbus-1/services/org.freedesktop.FileManager1.service

(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]
Name=org.freedesktop.FileManager1
Exec=/usr/bin/nautilus --gapplication-service