I installed VS Code, and for some reason, it because the default file manager for opening directories. Gnome Setting’s Default Applications have entries for Web, Mail, Calendar, Music, etc, but not default file manager. Opening a directory with “Open with…” allowed me to open a directory with Files, but unlike the cases of other file types, it had no “Always use for this file type” checkbox, so I could not set the default.
After searching the web and some trial-and-error, I figured out that I need to run
in the terminal, but this is NOT user-friendly. I wonder why Settings don’t have a drop-down for the default file browser? If this is because there is no way to get the list of installed file managers, at least a “Restore default file manager (Gnome Files)” button would be helpful there.
That’s because your distribution is not shipping a list of default applications for common MIME types.
Ideally, GNOME would ship that file, but then every distribution would end up changing something because what GNOME considers a “default application” may very well be not what a downstream distributor considers a default—for instance, because they ship something different, or because they don’t ship that application at all.
Some downstream distributors—like Fedora and Ubuntu—do provide defaults that match what they ship, but there are distributors that don’t want to make that decision, so whenever you install an application that handles a MIME type, and whose name comes before Nautilus in the lexicographical order, you’ll get that application as the default.
Because there are thousands of possible MIME types, and each one of them can have a default application.
This is a longstanding defect that we ought to fix. We should ship some base defaults somewhere and distros can override as desired. I think @hadess wanted to put them in the gnome-desktop package. I’m not sure if that’s really the best place, but I can’t exactly think of anything better either.
AFAIR, we were waiting to have a proper consolidated list of core applications before committing to that. These days we have a more formal structure, so I think we can add it, it’s just that nobody found the time to do it.
I mean, if we want to go into the weeds: that whole page of the settings should just go away at this point.
The MIME types it represents are undocumented (I had to add a flavour of OGG to include Amberol in the music players list, and only after looking at the code), and the scopes are entirely arbitrary. Some of them are MIME types, some are URI scheme handlers, and some cannot be added because they don’t match either.
The default MIME type and URI scheme type handlers for GNOME should replace them; then we’d need some additional UI into the Applications settings to mark an application as the default without necessarily going through Nautilus.
I don’t understand this explanation. If default file manager cannot be displayed because my distribution does not have the list, how come Settings can have default applications for other types of applications? Here is the screenshot of the Settings of my distribution:
Settings allows changing defaults for particular MIME types.
If you don’t have any defaults at all, I think GNOME will launch whichever comes first alphabetically. VS Code probably sorts alphabetically higher than nautilus (“com.visualstudio.code” vs. “org.gnome.Nautilus”). So there you have it. All major distributions ship defaults to prefer nautilus or their default file manager, except Arch. Maybe some other smaller distros don’t either.
I kind of feel like repeating myself, but why not have GUI default application settings for file manager using inode/directory? That is the type I used for the command-line command. Not only a weird case like VS Code, people may want to install multiple versions of file managers (such as Dolphin, Thunar, etc) and want to test each of them for a while, and currently they would have to change the default file manager via command-line.