I have tried to install a new mime-type for textfiles with a .w extension as follows:

<?xml version="1.0"?>
<!-- In file ~/.local/share/mime/packages/w.xml -->
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="text/w">
    <comment>File of w type</comment>
    <glob pattern="*.w" />

After running update-mime-database ~/.local/share/mime, any non-empty file with the extension .w is correctly identified in my file-browser as being a text/w file. However, if that file is empty, then it is identified simply as text/plain instead.

Why does this happen? Is this a bug or is it expected behaviour? Is there any way to also get empty files with a .w extension to show up as being of type text/w?

Update: using the mimetype command (as discussed here), as opposed to xdg-mime query filetype or file --mime-type returns the right result even if the file is empty. So presumably the partial answer to my question is that presumably nemo relies on xdg-mime internally. Is there any way to fix this in general via the mime xml definition, or should I simply be raising a bug to nemo to use mimetype instead of xdg-mime instead?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.