3

I'm running Arch Linux and KDE. I have installed Arch KDE on several devices and in the usual case there is no specific mime-type association for .pub files (which are public keys in my case). They will be opened by the default handler for plain text documents. This is what I expect to see on my standard Arch Linux install:

$ xdg-mime query filetype id_rsa_test.pub
text/plain

However, on my main desktop, .pub files are associated with ms-publisher.

$ xdg-mime query filetype id_rsa_test.pub
application/vnd.ms-publisher

I want to remove this association completely. Here are some of the places I found evidence of this association:

$ grep -irl '.pub' ./.local/share/mime/
./.local/share/mime/packages/application-vnd.ms-publisher.xml
./.local/share/mime/application/vnd.ms-publisher.xml
./.local/share/mime/globs
./.local/share/mime/globs2
./.local/share/mime/types
./.local/share/mime/mime.cache

$ sudo grep -irl 'ms-publisher' /usr
/usr/share/applications/mimeinfo.cache
/usr/share/mime/packages/freedesktop.org.xml
/usr/share/mime/application/vnd.ms-publisher.xml
/usr/share/mime/globs
/usr/share/mime/globs2
/usr/share/mime/subclasses
/usr/share/mime/types
/usr/share/mime/mime.cache
/usr/share/icons/breeze/mimetypes/64/application-vnd.ms-publisher.svg
/usr/share/icons/breeze/mimetypes/22/application-vnd.ms-publisher.svg
/usr/share/icons/breeze/breeze-icons.rcc
/usr/share/icons/breeze/icon-theme.cache
/usr/share/icons/breeze-dark/mimetypes/22/application-vnd.ms-publisher.svg
/usr/share/icons/breeze-dark/breeze-icons-dark.rcc
/usr/share/icons/breeze-dark/icon-theme.cache
/usr/lib/libreoffice/share/xdg/draw.desktop

According to the xdg-mime man page, the uninstall command might do the trick. In my case at least, the uninstall command has no effect.

# xdg-mime uninstall /usr/share/mime/application/vnd.ms-publisher.xml
# echo $?
0

# sudo grep -irl 'ms-publisher' /usr
/usr/share/file/misc/magic.mgc
/usr/share/applications/mimeinfo.cache
/usr/share/mime/packages/freedesktop.org.xml
/usr/share/mime/application/vnd.ms-publisher.xml
/usr/share/mime/globs
/usr/share/mime/globs2
/usr/share/mime/subclasses
/usr/share/mime/types
/usr/share/mime/mime.cache
/usr/share/icons/breeze/mimetypes/64/application-vnd.ms-publisher.svg
/usr/share/icons/breeze/mimetypes/22/application-vnd.ms-publisher.svg
/usr/share/icons/breeze/breeze-icons.rcc
/usr/share/icons/breeze/icon-theme.cache
/usr/share/icons/breeze-dark/mimetypes/22/application-vnd.ms-publisher.svg
/usr/share/icons/breeze-dark/breeze-icons-dark.rcc
/usr/share/icons/breeze-dark/icon-theme.cache
/usr/lib/libreoffice/share/xdg/draw.desktop

# grep -irl '.pub' /usr/share/mime/
/usr/share/mime/packages/freedesktop.org.xml
/usr/share/mime/packages/calibre-mimetypes.xml
/usr/share/mime/application/pkcs7-mime.xml
/usr/share/mime/application/pkcs8-encrypted.xml
/usr/share/mime/application/epub+zip.xml
/usr/share/mime/application/x-pkcs7-certificates.xml
/usr/share/mime/application/pkcs8.xml
/usr/share/mime/application/pkcs10.xml
/usr/share/mime/application/pkcs12.xml
/usr/share/mime/application/vnd.ms-publisher.xml
/usr/share/mime/globs
/usr/share/mime/globs2
/usr/share/mime/magic
/usr/share/mime/subclasses
/usr/share/mime/types
/usr/share/mime/generic-icons
/usr/share/mime/mime.cache

For my question, I want to know generally how to remove any mime-type association from my system using only CLI tools.

EDIT: response to answer:

On a new user account I show the following:

sudo pacman -Qs shared-mime-info
local/shared-mime-info 1.15-2
    Freedesktop.org Shared MIME Info

$ xdg-mime query filetype id_rsa_test.pub
text/plain

$ xdg-mime query default text/plain
atom.desktop

$ less ~/.config/mimeapps.list
/home/deleteme/.config/mimeapps.list: No such file or directory

This system has been updated multiple times (every day) and the ms-publisher association with .pub files has not come back. Note that this system has shared-mime-info installed and I am able to open public key files with a plain text editor, as I expect. In another user account on this system, I have my preferred association via an entry in ~/.config/mimeapps.list for that user.

$ xdg-mime query default text/plain
org.kde.kate.desktop

Back to the main question: How do I completely remove the association of .pub files with Okular and/or Libre Office Draw at the system level? Even if that's not an approved method, how do I do it?

2

.pub files will be opened by the default handler for plain text documents. This is what I expect to see on my standard Arch Linux

There is no reason you should expect this. The shared-mime-info package assumes .pub is a Microsoft Publisher document. If you think the default should be plain/text, then you need to report this upstream.

I, myself, think it's a bug and they should not make a M$ proprietary format extension a priority over a GNU/linux native file extension. Or better still to use use magic in addition to glob

I want to know generally how to remove any mime-type association from my system using only CLI tools

You shouldn't remove system-wide mime-type associations at all. Even if you managed to do it, it would come back later with system updates.

What you should do is to add your own mime type that overwrites the system one. As you already know from your other question here, you can use glob-deleteall to overwrite the previous definitions

| improve this answer | |
  • I updated the question. I appreciate this answer, and it does help, but I still want to know how to remove ms-publisher. It is not present on other Arch installs and they work fine. I want to get it off of my system, one way or the other. – MountainX Jan 30 at 22:41
  • On most of my Arch installs, things work like I expect without any user configuration (i.e., no entries in ~/.config/mimeapps.list) . But on my main desktop .pub files have an unacceptable association. Most of all, I want to know how to remove that without using ~/.config/mimeapps.list. I know it can be done because that's the situation I see on my other devices. – MountainX Jan 30 at 23:11
  • @MountainX-for-Monica: you said ms-publisher association is not present on other Arch installs but this is not true, it's available in all Arch's. To have different associations in different systems is normal even if you didn't customize it because it depends on the packages installed in each system and may be the order they are installed. You don't need to use mimeapps.list manually just right-click the app and associate it with your desired app – Munzir Taha Jan 31 at 4:49
  • Right clicking to associate is just another way of using ~/.config/mimeapps.list. I am seeing a certain behavior when the user has no ~/.config/mimeapps.list and I want to understand how / why that is happening. – MountainX Jan 31 at 18:16
  • @MountainX-for-Monica: I already explained the why part. I am not sure what's your remaining issue. – Munzir Taha Jan 31 at 19:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.