In fact I actually went to the trouble of writing a whole bunch of code to work around the brokenness of xdg-utils, precisely for this problem, that it would change default associations even when simply told of the existence of a new rogram.
https://github.com/kovidgoyal/calibr...e/linux.py#L57