KDE File Associations (reverse view)

In KDE we have System Settings->File Associations that shows which applications are associated with a specific file type. Is it possible to have a reverse view this relationship? That is: to show which file types are associated with a certain application?

This is impossible or need external app (I don’t know if it exists). As an option you can see mimetypes in *.desktop files in /usr/share/applications/.

There is xdg-mime command that will show the same info as the KDE Settings GUI.

xdg-mime query default $(xdg-mime query filetype /usr/bin/firefox)
OR
xdg-mime query filetype /usr/bin/firefox
xdg-mime query default application/x-shellscript

The commands below might help answer your reverse mimetype questions (good question :slight_smile:). I used firefox in all examples, so change that to the application/program name that meets your needs.

Search directories for FILES and pipe to xargs to grep and search for FILE (i.e.firefox).

find "$HOME"'/.config' \
     "$HOME"'/.local' \
     '/usr/local/share/applications/' \
     '/usr/share/applications' \
  -type f  \
  \( -iname 'mimeapps.list' \
     -o -iname \
     -o -iname '*defaults.list' \
     -o -iname '*mimeinfo.cache' \) \
  -print0 |
  xargs --null --max-args=1 --verbose \
    grep -i --color='always' -e 'firefox'

Search directories for *FILE*.desktop and pipe to xargs to execute sed. sed will search the
file for “MimeType” and convert “=” “;” to newline for easier viewing.

find "$HOME"'/.config' \
     "$HOME"'/.local' \
     '/usr/local/share/applications/' \
     '/usr/share/applications' \
  -type f  \
  -iname '*fire*desktop' \
  -print0 |
  xargs --null --max-args=1 --verbose \
    sed -rn "/MimeType/{s/[;=]/\\n/g;p}"

Yes, thanks. That’s what I resorted to already.

Nice workaround, even though it seemed so natural to me having this function inside the GUI…

I think plasma feature requests go here: https://bugs.kde.org.
There is also a forum for discussing ideas, Brainstorm at: https://forum.kde.org/