wrong mime-type displayed for empty text files

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












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" />
</mime-type>
</mime-info>


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?







share|improve this question






















  • There is now a formal bug request on github on this: github.com/linuxmint/nemo/issues/1792
    – Tasos Papastylianou
    Jul 10 at 10:41














up vote
3
down vote

favorite












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" />
</mime-type>
</mime-info>


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?







share|improve this question






















  • There is now a formal bug request on github on this: github.com/linuxmint/nemo/issues/1792
    – Tasos Papastylianou
    Jul 10 at 10:41












up vote
3
down vote

favorite









up vote
3
down vote

favorite











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" />
</mime-type>
</mime-info>


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?







share|improve this question














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" />
</mime-type>
</mime-info>


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?









share|improve this question













share|improve this question




share|improve this question








edited Feb 28 at 16:08

























asked Feb 27 at 14:30









Tasos Papastylianou

1214




1214











  • There is now a formal bug request on github on this: github.com/linuxmint/nemo/issues/1792
    – Tasos Papastylianou
    Jul 10 at 10:41
















  • There is now a formal bug request on github on this: github.com/linuxmint/nemo/issues/1792
    – Tasos Papastylianou
    Jul 10 at 10:41















There is now a formal bug request on github on this: github.com/linuxmint/nemo/issues/1792
– Tasos Papastylianou
Jul 10 at 10:41




There is now a formal bug request on github on this: github.com/linuxmint/nemo/issues/1792
– Tasos Papastylianou
Jul 10 at 10:41















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426952%2fwrong-mime-type-displayed-for-empty-text-files%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426952%2fwrong-mime-type-displayed-for-empty-text-files%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)