4

Using LXQT, the file manager (PCManFM-QT) is showing all files with unrecognized suffixes as "text/plain". I've added an entry to /etc/mime.types mapping a new suffix to a new application/x-app-here type, but the file still show up as plain text. I'd like to be able to map these files to the correct application without launching that app by default for all plaintext files. What am I missing?

guiverc
  • 28,623
  • 5
  • 46
  • 74
Mark Reed
  • 211
  • 1
  • 10

1 Answers1

3

The solution is to register a new type with XDG using xdg-mime. Create an XML file like this:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-foobar">
        <comment>foo file</comment>
        <icon name="application-x-foobar"/>
        <glob-deleteall/>
        <glob pattern="*.foo"/>
    </mime-type>
</mime-info>

Name it x-foobar.xml in this case, and run sudo xdg-mime x-foobar.xml to activate the new type.

Mark Reed
  • 211
  • 1
  • 10
  • Pardon my ignorance: after you've run the new file through xdg-mime, can you get rid of it or pack it away in case you need it after an OS upgrade? That is to say, is the file itself important? – MDeBusk Jun 20 '22 at 02:35
  • 1
    Running `xdg-mime` actually copies the file into a system location (`/usr/share/mime/packages/`), so you don't need the file anymore and can always get it back out. But of course it doesn't hurt to keep a copy around, maybe commit it into a repo with others, etc. – Mark Reed Jun 20 '22 at 02:48