Skip to main content
6 of 8
major revision to clarify and add more info
MountainX
  • 19k
  • 66
  • 172
  • 289

Okular is being used to handle SSH public keys (*.pub). Unable to remove this association

While using an electron desktop app, when I try to download an SSH public key with a .pub extension, KDE opens Okular.

I prefer no app be opened. I want to save those files directly to disk. How can I accomplish that?

Previously, using Dolphin and the File Types dialog, I had already (long ago) associated the .pub extension with Kate (no other apps). I was surprised to see Okular being used for .pub files given my settings.

Investigating this, I found ./.local/share/mime/application/vnd.ms-publisher.xml :

<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/vnd.ms-publisher">
<!--Created automatically by update-mime-database. DO NOT EDIT!-->
<comment>Public Key (plain text)</comment>
<glob-deleteall/>
<glob pattern="*.pub"/>
</mime-type>

I deleted it and ran:

$ update-mime-database ./.local/share/mime

That gave me a new mime.cache file

$ ls ./.local/share/mime/mime.cache
-rw-rw---- 1 user user 1300 Jan 20 17:09 ./.local/share/mime/mime.cache

I still have this association:

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

As mentioned, Kate is associated with that type, but Okular is still handling vnd.ms-publisher types in in the case of this electron app. Furthermore, this returns no result (while Kate would be the expected result):

$ xdg-mime query default application/vnd.ms-publisher

Given that the problem persists, I asked this question. That gives me more insight, but I have not been able to resolve my problem.

1) How do I stop Okular from handling files with .pub extensions and 2) how do I make this electron app save .pub files instead of launching an app?

The developers tell me their app does not have any special behavior this handling files -- it is all handled by the OS.

The only is mimeapps.list file on my entire system is:

~/.config/mimeapps.list
and the above is symlinked to /.local/share/applications/mimeapps.list

However, look at these unexpected & inconsistent results I get. First, I expected this to use the Kate association:

$ xdg-open id_rsa.pub
No file found for "application/vnd.ms-publisher.xml" , even though update-mime-info said it would exist.
Either it was just removed, or the directory doesn't have executable permission... ("~/.local/share/mime", "/usr/share/mime")

Running the same with sudo gives a different result and another unexpected result:

sudo xdg-open id_rsa.pub
opens it in Atom text editor (which I don't have configured for this type anywhere)

Next, this returns nothing:

$ xdg-mime query default application/vnd.ms-publisher

Finally, another inconsistent and another unexpected result:

sudo xdg-mime query default application/vnd.ms-publisher
libreoffice-draw.desktop

None of this is expected. I simply want to put this all in order. What are the steps?

I am running latest KDE Plasma 5 on Arch Linux.

EDIT: In response to comment by @ajgringo619

$ grep '.pub' $HOME/.config/mimeapps.list

[Added Associations]
application/vnd.ms-publisher=org.kde.kate.desktop;

[Default Applications]
application/vnd.ms-publisher=org.kde.kate.desktop;

[Removed Associations]
application/vnd.ms-publisher=libreoffice-draw.desktop;okularApplication_pdf.desktop;libreoffice-writer.desktop;org.kde.gwenview.desktop;
MountainX
  • 19k
  • 66
  • 172
  • 289