--- /dev/null
+#!/bin/sh
+# From https://blog.hexadust.net/xdg-open-setting-default-handler-for-supported-mime-types
+D=$1
+if test -z "$D"; then
+ find /usr/share/applications/ ~/.local/share/applications/ -name '*.desktop' | while read DF; do
+ D=`basename "$DF"`
+ echo $D
+ cat "$DF" | grep MimeType | cut -f2 -d= | tr ';' "\n" | grep -v '^$' | while read M; do
+ echo -ne "\t$M current: "
+ xdg-mime query default "$M"
+ done
+ echo
+ done
+fi
+if test -n "$D"; then
+ find /usr/share/applications/ ~/.local/share/applications/ -name "$D" | while read DF; do
+ cat "$DF" | grep MimeType | cut -f2 -d= | tr ';' "\n" | grep -v '^$' | while read M; do
+ echo "Using $D for $M"
+ xdg-mime default "$D" "$M"
+ done
+ done
+fi