You are not logged in.

#1 2023-04-27 07:43:01

admin
Member
Registered: 2022-04-28
Posts: 13

dbus-send ShowItems doesn't use the default file manager?

The following command does not seem to locate a file with the file manager that is specified by `xdg-mime query default  inode/directory`. It opens another file manager than the default one, but if the default one is already running, then it opens another instance of the default one.

dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 
--type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems 
array:string:"file:////bin" string:""

I had this problem with Arch-derivative OS's, but it did not seem to occur on Ubuntu. So, I tried it on Arch (with a new installation with Gnome destktop using archinstall), and I could reproduce the problem.

Why is this so? Is this a bug of Gnome or some sub-system? Or did I use a wrong command to "locate a file with the default file manager"? If it is the latter, what is the correct command?

Steps to reproduce

* Install Arch with profile "Desktop" - "Gnome".
* Install `nemo`
* Reboot  and `xdg-mime query default  inode/directory` to make sure that the default FM is "Nemo".
* Run the command above

Result: Gnome Files (nautilus) is open, instead of Nemo, when Nemo is the default file manager. If I open Gnome Disks and select the root partition, and click the "Filesystem Root" link, it opens Nemo.

Screen recording of the steps and the problem: https://i.imgur.com/TA77yhA.mp4

Offline

#2 2023-04-27 08:51:12

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,292

Re: dbus-send ShowItems doesn't use the default file manager?

It opens the file manager that is registered in dbus as that file manager. the dbus call is not set nor read nor calls into xdg-open so showing that xdg-open is your default is irrelevant. if you want to change that you need to change the order of the manager registered in DBUS, assuming nemo implements that as well: https://wiki.archlinux.org/title/File_m … lity#D-Bus

Offline

#3 2023-04-27 14:26:48

admin
Member
Registered: 2022-04-28
Posts: 13

Re: dbus-send ShowItems doesn't use the default file manager?

V1del wrote:

It opens the file manager that is registered in dbus as that file manager. the dbus call is not set nor read nor calls into xdg-open so showing that xdg-open is your default is irrelevant. if you want to change that you need to change the order of the manager registered in DBUS, assuming nemo implements that as well: https://wiki.archlinux.org/title/File_m … lity#D-Bus

This is a confusing part. In Gnome's Settings -> Default Applications, there is no "Default file manager" option. If you search Google, then a lot of people mention xdg-mime. For example, the top search result is this reddit post ( https://www.reddit.com/r/gnome/comments … _in_gnome/ ), which refers to Arch wiki ( https://wiki.archlinux.org/title/Xdg-utils#xdg-mime ) that says

    To set a file manager as the default file manager (for ex -Thunar) type:
    xdg-mime default thunar.desktop inode/directory

and of course, getting the current default is said to be `xdg-mime query default  inode/directory`. When I searched Google for a way to locate a file with the default file manager in Linux, results say "dbus-send ..." command is the answer.

I just checked my Arch installation, and the content of `/usr/share/dbus-1/services/org.freedesktop.FileManager1.service` was

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

which was different from the `xdg-mime default`.

So, which of my action above was wrong, the way to set the default file manager, or the way to locate a file with the default file manager? If it is the former, then I should have set the default file manager by modifying the `FileManager1.service` file. If is the latter, then what command should I use to locate the file with the default manager that was set by "xdg-mime default..."?

Last edited by admin (2023-04-27 14:36:49)

Offline

#4 2023-04-27 14:43:38

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,292

Re: dbus-send ShowItems doesn't use the default file manager?

Both, and I'd assume xdg predates the DBUS registration. It all depends on what the application you're using intends to do and how it tries to invoke the file manager, xdg-open is limited and can only call a binary with potentially specific flags, dbus allows a file manager to register on a standardized interface that everyone should be agreeing to that should lead to the same end result regardless of what integrates it.

What use-case do you have for running dbus-send explicitly? As stated there you could either override it locally, or generally ensure that the file manager you actually want to use registers "first" on dbus.

Last edited by V1del (2023-04-27 14:46:16)

Offline

#5 2023-04-27 14:53:02

admin
Member
Registered: 2022-04-28
Posts: 13

Re: dbus-send ShowItems doesn't use the default file manager?

V1del wrote:

Both, and I'd assume xdg predates the DBUS registration. It all depends on what the application you're using intends to do and how it tries to invoke the file manager, xdg-open is limited and can only call a binary with potentially specific flags, dbus allows a file manager to register on a standardized interface that everyone should be agreeing to that should lead to the same end result regardless of what integrates it.

What use-case do you have for running dbus-send explicitly?

I am writing an application, which displays a list of files and lets the user to locate the file with the default file manager. This feature is not uncommon. For example, in a lot of IDE's or code editors, if you right-click a file, it has some kind of way to locate the file in the default file manager.

For example, JetBrain's IDE, like Android Studio, has this feature. You can right-click a file in the Project tree, and choose "Open in". In the secondary menu, it seems to show the current default file manager that was set  by `xdg-mime default ...  inode/directory`, and it correctly opens the default file manager. I have tested it with setting Gnome Files and Nemo, and one strange thing is that JetBrain's IDE cannot select the file, if the default file manager set by `xdg-mime` is Nemo, whereas if I select a file with the dbus-send command, Nemo can select the file.

I wonder if JetBrain's IDE is not using dbus-send when the default file manager is Nemo.

Anyway, maybe this is not a problem specific to Arch, but more like xdg-mime and dbus-send, so maybe I should ask a forum that is more dedicated to those technologies.

Thanks.

Last edited by admin (2023-04-27 14:54:21)

Offline

#6 2023-04-27 16:08:24

3beb6e7c46a615a
Member
Registered: 2021-03-27
Posts: 165

Re: dbus-send ShowItems doesn't use the default file manager?

xdg-mime doesn't set the "default file manager", it sets the default program to open a directory with.

That's a crucial difference: All IntelliJ can do over this interface is to open the parent directory of the desired file, and that's it.  There's no way to tell the program to select a certain file in that directory, that's just not possible over this interface. Technically you don't have to use a file manager as a default program to open a directory, after all. You could also use eg your text editor or something else.

That's why the file manager interface exists in the first place: The xdg-mime stuff is just insufficient for anything beyond "open a directory". It can't even do the "open a directory and select this file" thing which is somehow essential for a file manager ^^

Offline

#7 2023-04-27 18:03:00

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,292

Re: dbus-send ShowItems doesn't use the default file manager?

So now that we have the X to the Y, your application should be doing both, check whether a file manager is registered at that DBUS end point or fall back to xdg-open in case it isn't, with the caveat that your "select a specific file" use case will not work for the latter.

Offline

Board footer

Powered by FluxBB