It all started with Visual Studio Code crashing when I tried to open the file. After troubleshooting it seems I pinned it down to an issue with MIME. Now running against the behavior I can't wrap my head around.
Basically my handlers for images stopped working. I can create a new handler for using xdg-mime
, but when I query it or try to use opener it fails to pick the right handler.
According to manual the $XDG_CONFIG_HOME/mimeapps.list
is supposed to take precedence. The file has the right format. And xdg-mime seems to write to it, but can't query it for some reason.
- Adding new handler
~ main• ❱ env XDG_UTILS_DEBUG_LEVEL=2 xdg-mime default feh.desktop image/jpeg
make_default_kde: No kde runtime detected
make_default_generic feh.desktop image/jpeg
Updating /home/om/.config/mimeapps.list
- Checking it was added
~ main• ❱ cat $XDG_CONFIG_HOME/mimeapps.list | grep image/jpeg
image/jpeg=feh.desktop
xdg-mime query
doesn't see it, although it checks the right file first
~ main• ❱ env XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default image/jpeg
Checking /home/om/.config/mimeapps.list
Checking /home/om/.local/share/applications/mimeapps.list
Checking /home/om/.local/share/applications/mimeapps.list
Checking /home/om/.local/share/applications/defaults.list and /home/om/.local/share/applications/mimeinfo.cache
Checking /home/om/.local/share/applications/defaults.list and /home/om/.local/share/applications/mimeinfo.cache
Checking /home/om/.local/share/applications/defaults.list and /home/om/.local/share/applications/mimeinfo.cache
Checking /home/om/.local/share/applications/defaults.list and /home/om/.local/share/applications/mimeinfo.cache
In this case the problem was with environment variables. I realized that the
/home/om/.local/share/applications/defaults.list
was overriding the/home/om/.config/mimeapps.list
.After I symlinked
defaults.list
tomimeapps.list
it solved the problem, but that seemed a bit hacky.Later I discovered that I had
XDG_DATA_DIRS
mixed withXDG_DATA_HOME
, i.e.:XDG_DATA_DIRS=$HOME/.local/share
, which I suspect was confusing the system-wide mime list with user-specific. After I unset theXDG_DATA_DIRS
and setXDG_DATA_HOME
to$HOME/.local/share
thexdg-mime
no longer looks for other files:Ref: basedir-spec