Mime database / overriding specific extension

On my Rocky 9.2 system, the mime type association for a .key file is:

# cat /usr/share/mime/globs | egrep "\.key$"
application/vnd.apple.keynote:*.key
application/pgp-keys:*.key

When I send an email with a .key file attached, it set’s it’s mime type to application/vnd.apple.keynote.

I want to change the association for *.key to application/octet-stream.

As instructed by upstream vendor docs, I created a new mime definition file:

# cat /usr/share/mime/packages/application-octet-stream.xml 
<?xml version="1.0" encoding="UTF-8"?>

<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/octet-stream">
    <comment>new mime type</comment>
    <glob pattern="*.key"/>
  </mime-type>
</mime-info>

and updated the database:

# update-mime-database /usr/share/mime

Indeed now the mapping is present:

# cat /usr/share/mime/globs | egrep "\.key$"
application/vnd.apple.keynote:*.key
application/octet-stream:*.key
application/pgp-keys:*.key

However, it does not seem to have had any effect on gnome:

# gio info /path/to/license60.key
display name: license60.key
...
attributes:
  standard::type: 1
  standard::name: license60.key
...
  standard::icon: application-pgp-keys, text-x-generic, application-pgp-keys-symbolic, text-x-generic-symbolic
  standard::content-type: application/pgp-keys
  standard::fast-content-type: application/vnd.apple.keynote
  standard::size: 434
  standard::allocated-size: 4096
  standard::symbolic-icon: application-pgp-keys-symbolic, text-x-generic-symbolic, application-pgp-keys, text-x-generic
  etag::value: 1617386443:0
...

After restarting my mailer and sending a test email with a .key file attached, the attachment is still sent as application/vnd.apple.keynote.

So apparently my changes had no effect.

Note that if I just manually delete the other two .key associations in /usr/share/mime/globs, restart my mailer and send a test email, it does correctly use application/octet-stream. But of course this will not persist.

How do I completely, permanently and properly change the mime association for an extension?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.