Ubuntu – How to change all file associations (MIME-types) of one particular application in KDE

file associationkdekubuntulibreofficemime-type

I have installed a closed source office suite called Freeoffice. Generally, I use Libreoffice for all my work and need Freeoffice only as a backup to check if there are any inconsistencies in formatting when i need to edit collaborative docx documents and send them to MSOffice using clients.

My problem is, that each time I update Freeoffice it sets itself as the default application for all office related document formats. I then have to manually change each of them, which I often forget as there is a ton of related Mime types.

Is there a way to find all MimeTypes that are associated with Freeoffice and decrease its rank, so that it is no longer the default?

PS: I use Kubuntu 19.04 and am in search of a KDE solution.

Best Answer

FreeOffice sets its file associations in ~/.config/mimeapps.list (also in /usr/share/applications/defaults.list but they get overriden by ~/.config/mimeapps.list).

You can use the following sed command to replace the FreeOffice entries with the respective LibreOffice ones in ~/.config/mimeapps.list:

sed -i -e 's/textmaker-free18/libreoffice-writer/g' -e 's/planmaker-free18/libreoffice-calc/g' -e 's/presentations-free18/libreoffice-impress/g' ~/.config/mimeapps.list

The above apply to all Ubuntu desktop environments, not only KDE.


Edit

In OP's case ~/.config/mimeapps.list does not override /usr/share/applications/defaults.list. In this case one has to run the same sed command for the /usr/share/applications/defaults.list file:

sed -i -e 's/textmaker-free18/libreoffice-writer/g' -e 's/planmaker-free18/libreoffice-calc/g' -e 's/presentations-free18/libreoffice-impress/g' /usr/share/applications/defaults.list