How to easily adapt MIME types for a parallel installation of a newer version

This question pertains to the LibreOffice package as a whole:

I have more than one installed version of LibreOffice in parallel un my Xubuntu system. For most of the time, I use a recent version of the development branch. But sometimes I go back to an older established version

The MIME types are associated to the first version which was installed.

However, I would like to associate all MIME types relating to LibreOffice to one specific version. I have only seen xfce4-mime-settings offering me to manually assign zillions of application/vnd.oasis.opendocument.xxxxx or application/vnd.msword.xxxx or application/vnd.sun.xxxx all dealing with LibreOffice which I would like to direct to the proper component of say LibreOfficeDev. xfce4-mime-settings does not offer me something to alter a whole bunch of them together. But I think, there must be some better way and probably I am not the first and only one with this problem.

Modifying the association list will be tedious and error prone because there are zillions entries to change and change them consistently.

The idea could be instead to cheat the OS.

Looking at the list with my KDE Plasma configuration module, I see that e.g. .odt resolve to libreoffice --writer %U. libreoffice itself resolve through $PATH to script /usr/lib/libreoffice which launches the adequate binary.

Then if you want to redirect to another instance of LO, either change the small script in /usr/lib (not recommended) or patch your $PATH variable. The latter is safer as it does not involve mixing with system libraries.

Create a .mailcap file in your $HOME directory, so $HOME/.mailcap, with the following content and replacing /path/to/your/bin/ with the actual path of course:

application/vnd.oasis.opendocument.base;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.chart;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.chart-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.database;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.formula;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.formula-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.graphics;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.graphics-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.image;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.image-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.presentation;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.presentation-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.spreadsheet;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.spreadsheet-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.text;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.text-master;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.text-template;/path/to/your/bin/soffice %s
application/vnd.oasis.opendocument.text-web;/path/to/your/bin/soffice %s

application/vnd.sun.xml.writer;/path/to/your/bin/soffice %s
application/vnd.sun.xml.writer.global;/path/to/your/bin/soffice %s
application/vnd.stardivision.writer;/path/to/your/bin/soffice %s
application/vnd.stardivision.writer-global;/path/to/your/bin/soffice %s
application/x-starwriter;/path/to/your/bin/soffice %s
application/vnd.sun.xml.writer.template;/path/to/your/bin/soffice %s
application/vnd.sun.xml.calc;/path/to/your/bin/soffice %s
application/vnd.stardivision.calc;/path/to/your/bin/soffice %s
application/x-starcalc;/path/to/your/bin/soffice %s
application/vnd.sun.xml.calc.template;/path/to/your/bin/soffice %s
application/vnd.sun.xml.impress;/path/to/your/bin/soffice %s
application/vnd.stardivision.impress;/path/to/your/bin/soffice %s
application/vnd.stardivision.impress-packed;/path/to/your/bin/soffice %s
application/x-starimpress;/path/to/your/bin/soffice %s
application/vnd.sun.xml.impress.template;/path/to/your/bin/soffice %s
application/vnd.sun.xml.draw;/path/to/your/bin/soffice %s
application/vnd.stardivision.draw;/path/to/your/bin/soffice %s
application/x-stardraw;/path/to/your/bin/soffice %s
application/vnd.sun.xml.draw.template;/path/to/your/bin/soffice %s
application/vnd.sun.xml.math;/path/to/your/bin/soffice %s
application/vnd.stardivision.math;/path/to/your/bin/soffice %s
application/x-starmath;/path/to/your/bin/soffice %s

application/vnd.ms-word;/path/to/your/bin/soffice %s
application/x-msword;/path/to/your/bin/soffice %s
application/msword;/path/to/your/bin/soffice %s
application/vnd.ms-excel;/path/to/your/bin/soffice %s
application/x-msexcel;/path/to/your/bin/soffice %s
application/x-ms-excel;/path/to/your/bin/soffice %s
application/x-excel;/path/to/your/bin/soffice %s
application/msexcel;/path/to/your/bin/soffice %s
application/msexcell;/path/to/your/bin/soffice %s
application/x-xls;/path/to/your/bin/soffice %s
application/vnd.ms-powerpoint;/path/to/your/bin/soffice %s
application/x-mspowerpoint;/path/to/your/bin/soffice %s
application/mspowerpoint;/path/to/your/bin/soffice %s
application/vnd.openxmlformats-officedocument.spreadsheetml.document;/path/to/your/bin/soffice %s
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;/path/to/your/bin/soffice %s
application/vnd.openxmlformats-officedocument.wordprocessingml.document;/path/to/your/bin/soffice %s

(the list may contain some now outdated and maybe superfluous entries, it’s historically grown).

Well behaving programs consider and follow a ~/.mailcap file that overrides /etc/mailcap, like browsers and mail user agents.