How to change the default app for opening directories in Gnome?
I somehow managed to unknowingly change the default app for opening directories on my laptop. E.g. when I use the option open containing folder in a program like Evince, my editor (vscode) opens up instead of my file manager (Nautilus).
I have been experiencing this for some months now and it is not that much of a problem, but every time I stumble upon it I tend to start looking for solutions and every time I am unable to find a solution.
I am using Gnome and I know how to change the default apps for web, mail, calendar, music, video and photos in settings. I also checked Gnome tweaks and dconf editor, but searches for directory, folder and default do not seem to list any entries for default directory settings.
Does anybody know how to change the default app for opening directories in Gnome or where these settings could be stored?
Further Details
The answer of matthewsnyder seems to point in the right direction.
When opening a directory with xdg-open
, vscode is started instead of Nautilus.
However, when running
xdg-mime query default inode/directory
the output indicates that Nautilus should be the default app for opening directories again.
Even though xdg-open
clearly does not use Nautilus.
I also tried running in debug mode using
XDG_UTILS_DEBUG_LEVEL=10 xdg-open ~
but this only provides the following additional information: Selected DE gnome3
2 answers
By digging further into the details of xdg-open
, I stumbled upon this page in the Arch wiki.
There it states that xdg-open
will delegate the task of opening a file to the handler of the Desktop Environment (DE).
In the case of Gnome, this will be gio
.
My Solution
The available applications for opening a directory can be listed using
gio mime inode/directory
This effectively listed vscode as the default app! I eventually managed to overwrite this default to use Nautilus as follows
gio mime inode/directory org.gnome.Nautilus.desktop
General Solution
I am not sure how xdg-mime
and gio
got disconnected.
I verified that xdg-mime
also correctly delegates to gio
and there seem to be no problems there (at least after the fix).
Therefore, a more general (DE-independent) fix would probably be to use
xdg-mime default org.gnome.Nautilus.desktop inode/directory
to set the default app, even if xdg-mime query default
lists the correct result.
After all, xdg-mime
does seem to correctly delegate to the app used by the DE.
0 comment threads
I don't use Gnome, but I'm guessing it relies on xdg-open
to figure out what program to use.
Your first step would be to do xdg-open ~
to see if it uses the same incorrect program. If so, great - you can troubleshoot xdg-open. If not, Gnome decided to write their own file association resolver to use on top of xdg-open, so it's a Gnome-specific thing. Based on comments, this does not appear to be the case here - you say that xdg-open
behaves consistently with Gnome GUI.
When troubleshooting, you can use xdg-mime
to check how the filetype is being resolved. You can also use it to set associations. The Arch wiki has some tips.
Something to keep in mind: There is a cache for the MIME types, so simply setting an association with xdg-mime
may not be enough. You may also have to update the cache using the program update-mime-database
(man page). I think the cache is supposed to be a file called mime.cache
under XDG dirs (my Arch install doesn't have it). There is also a related ~/.config/mimeapps.list
although I'm not sure if this is also generated by programs like xdg-mime
.
You can also try handlr
which is an alternative to xdg-utils
. I think it edits the same MIME databases but has a "better" UI. I find xdg-utils
to have atrocious usability, so perhaps handlr
might be less unpleasant.
1 comment thread