In a program which I am writing I want to offer the functionality to open the directory where the file which I am currently processing is located and automatically select that file (so that the user does not need to search for it).
I know that I can open a directory in the default file manager using
xdg-open /path/to/directory
I know that I can open a directory in nautilus and select a file using
nautilus /path/to/file.txt
I thought that I could use
xdg-mime query default inode/directory
to get the default file manager and - if it is nautilus - call it as shown above.
But, despite the fact that nautilus is the default on my system (xdg-open
opens nautilus and so does the places menu in the gnome shell), xdg-mime
returns Thunar.desktop
.
(I have tried find / -name Thunar.desktop -mount 2>/dev/null
but it did not find anything.)
Also, I do not know how to open a directory and select a subdirectory in nautilus (with the above mentioned approach it would open the subdirectory).
How can I open a directory in the default filemanager and select a file in that directory (if selecting a directory, too, was possible that would be great, but for this application not needed) or at least find out the default filemanager so that I can call it directly?