1

The following command opens a file manager to show the directory.

dbus-send --session --dest=org.freedesktop.FileManager1 --print-reply \
 --type=method_call /org/freedesktop/FileManager1 \
 org.freedesktop.FileManager1.ShowItems array:string:"file:///path/to/your/directory" string:""

The problem is that the default file manager seems to be random. My guess is the last updated file manager, because it changed after a file manager was updated. Also, when a file manager is already running, it uses that file manager.

Instead of letting dbus-send determine which file manager to use, if I know which file managers are installed, can I set a specific file manager, like Nemo?

2
  • this feels like a specific problem with the update process of your distro (I guess this is on Linux); I wouldn't expect defaults to regularly change on minor updates! Which distro is that? Commented Jun 9, 2024 at 15:07
  • Arch; happens with two different derivatives of Arch. Commented Jun 12, 2024 at 16:38

1 Answer 1

0

dbus-daemon does not officially support multiple .services being set up to be activatable with the same bus name; it basically chooses one at random, and that is likely to change on every boot.

  • One way to make this work is have the file manager permanently run in background if it has such a mode (e.g. Nautilus does). That's how the org.freedesktop.Notifications service is provided by desktop environments – they do not rely on autostart (bus activation) but explicitly start the appropriate notification daemon as soon as you log in.

  • Another way is to send the bus message to a different --dest=. The file manager will usually have not only the generic bus name but also its own "branded" bus name, e.g. Thunar is also available at org.xfce.Thunar; you can list them using busctl --user or d-spy/d-feet.

    When a service has multiple names, it doesn't matter which name you send the D-Bus message to – they're all resolved to the same bus address (unique name) – so you can specify --dest=org.xfce.Thunar without changing anything about the rest of the command (i.e. specifically no change in the object path or the interface name).

    gdbus call -e -d org.xfce.Thunar \
                  -o /org/freedesktop/FileManager1 \
                  -m org.freedesktop.FileManager1.ShowItems \
                  "['file:///etc/passwd']" \
                  "''"
    
    busctl call --user org.gnome.Nautilus \
                      /org/freedesktop/FileManager1 \
                      org.freedesktop.FileManager1 \
                      ShowItems ass 1 file:///etc/passwd ""
    
  • The third way is to set up your package manager to not install the .service files for file managers which you don't want to be bus-activatable. Go through /usr/share/dbus-1/services and remove the ones you don't want.

    For example, on Arch Linux you could use NoExtract= in /etc/pacman.conf; on Debian you could dpkg-divert the unwanted files.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.