You are not logged in.

#1 2019-01-03 22:26:44

antimop
Member
Registered: 2016-01-20
Posts: 4

[SOLVED] Recognizing CBR and CBZ comics as distinct mime types

Currently CBR and CBZ files just appear to be rar and zip files.

$ xdg-mime query filetype foo.cbr
application/x-rar
$ xdg-mime query filetype baz.cbz
application/zip

I want these to be seen as different mime types so that I can specify that they should open with different default applications than plain old archives (specifically, mcomix).

It looks like there is a mime type already defined, which based on the glob pattern, ought to match correctly:

$ less /usr/share/mime/application/x-cbr.xml
<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-cbr">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <sub-class-of type="application/x-rar"/>
  <comment xml:lang="en">Comic Book Archive (RAR compressed)</comment>
  <glob pattern="*.cbr"/>
</mime-type>

It also looks like mcomix added its own definitions that do I want:

$ less /usr/share/mime/packages/mcomix.xml
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-cbz">
        <sub-class-of type="application/zip"/>
        <comment xml:lang="en">Comic Book Archive (Zip compressed)</comment>
        <glob pattern="*.cbz"/>
    </mime-type>
    <mime-type type="application/x-cbr">
        <sub-class-of type="application/x-rar"/>
        <comment xml:lang="en">Comic Book Archive (RAR compressed)</comment>
        <glob pattern="*.cbr"/>
    </mime-type>
    <mime-type type="application/x-cbt">
        <sub-class-of type="application/x-compressed-tar"/>
        <sub-class-of type="application/x-bzip-compressed-tar"/>
        <sub-class-of type="application/x-tar"/>
        <comment xml:lang="en">Comic Book Archive (tar, possibly compressed)</comment>
        <glob pattern="*.cbt"/>
    </mime-type>
    <mime-type type="application/x-cb7">
        <sub-class-of type="application/x-7z-compressed"/>
        <comment xml:lang="en">Comic Book Archive (7zip compressed)</comment>
        <glob pattern="*.cb7"/>
    </mime-type>
</mime-info>

Yet somehow xdg-open/xdg-utils still sees these files as normal archives. Is something overwriting the application/x-cbz and application/x-cbr mime types? Or does something need to be done to make them active?

Last edited by antimop (2019-01-04 00:15:10)

Offline

#2 2019-01-03 23:49:48

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: [SOLVED] Recognizing CBR and CBZ comics as distinct mime types

You'll have to install perl-file-mimeinfo. Otherwise xdg-open uses the output of the file command that only checks the file contents and not the name.

Last edited by progandy (2019-01-03 23:51:11)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#3 2019-01-04 00:16:24

antimop
Member
Registered: 2016-01-20
Posts: 4

Re: [SOLVED] Recognizing CBR and CBZ comics as distinct mime types

Thank you, installing that package got the files to be recognized as "application/vnd.comicbook+zip" and "application/vnd.comicbook-rar". I then added entries to /etc/xdg/mimeapps.list specifying that those two types should be open with mcomix.

Offline

Board footer

Powered by FluxBB