How to Setup an Application Using Xdg Mime
FleetingUsing drawio as an example.
Make sure the mimetype is recognized updating globs (see here to use the magic matching).
IFS=:
for i in ${XDG_DATA_DIRS}:${XDG_DATA_HOME}
do
cat $i/mime/globs
done|grep drawio
application/vnd.jgraph.mxfile:*.drawio
You can run mimeopen -d
(from libfile-mimeinfo-perl) to create the desktop
file and the association.
Then you get the association in the mimeapps file.
grep drawio ${XDG_CONFIG_HOME}/mimeapps.list
application/vnd.jgraph.mxfile=drawio-usercreated-1.desktop;
You can rename and move it to your convenience.
IFS=: read -a p <<< "${XDG_DATA_DIRS}:${XDG_DATA_HOME}"
for i in "${p[@]}"
do
if test -e ${i}/applications && ls ${i}/applications | grep -q drawio
then
echo found in ${i}
fi
done
found in somedirectory/share