How to find out the default file manager in the terminal?

I’m working on different Linux distributions.

In my .bashrc I’d like to set up an alias that opens a window of the default file manager (e.g. nautilus, nemo, pacman, …).

Is there a way find out what the file-manager of a session is? (It does also depends on the session, doesn’t it?)

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

As comments have already stated, you’re probably better off with xdg-open (no alias needed), but to answer the question: You can use xdg-mime to query and set default applications. To get the default file manager:

xdg-mime query default inode/directory

Read more about this topic in the xdg-mime manual or the Arch Wiki.

Solution 2

No, you can’t.

Or at least there’s no simple magic command for guessing what’s the current desktop’s default file manager.

All what xdg-open or xdg-mime query will do or tell you, is what has been associated to the desktop object type "folder" (inode/directory type), for the action "open". This is neither what defines a file manager in general, nor what defines what’s the desktop’s default one or what you expect.

What is associated to the inode/directory type could be whatever application you’ve installed that associates itself to directories (audacious does it – is that the file manager you’d expect? it’s not the only one).

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply