Using the steps in the accepted answer at the above question, I created the following mime-type mx-publickey.xml
<?xml version="1.0" encoding="utf-8"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="text/x-publickey"> <comment>Custom type for public key files (plain text)</comment> <glob-deleteall/> <glob pattern="*.pub"/> </mime-type> </mime-info>
I installed it system-wide with this command:
# xdg-mime install --mode system mx-publickey.xml
I added the desired icon:
xdg-icon-resource install --context mimetypes --size 256 x-publickey-icon.png text-x-publickey
Then I tested it. My '*.pub` files still have the old association:
$ xdg-mime query filetype id_rsa_test.pub text/plain $ xdg-mime query default text/plain org.kde.kate.desktop
What additional steps are required to associate '*.pub` files with my new mime-type?
I performed the following steps, but
*.pub public key files are still not being opened by default with Kate from Electron applications.
# xdg-mime default org.kde.kate.desktop text/x-publickey # xdg-mime query default text/x-publickey org.kde.kate.desktop $ xdg-mime query default text/x-publickey org.kde.kate.desktop
Next I used the GUI tools (KDE System Settings > Applications > File Associations) and associated
*.pub public key files with Kate. Electron applications still refuse to open
*.pub files with Kate.
Electron apps previously used Okular. Afer the
xdg-mime default command shown above, the Okular association is gone, but nothing has replaced it. Electron apps now present a KIO dialog asking me to pick the application to use. (That's better than forcing me to use the wrong application, but it is still not correct behavior. It appears Electron applications are looking other places for the file associations. I would like to understand that.)
Am I missing a needed
.desktop file in some location?
Another thought: After the above steps, I believe I should now see an entry for
/usr/share/applications/mimeinfo.cache. However, there is not one.