I grabbed a Linux expert in the office and we found a reasonable solution:
#!/bin/bash
EXTENSION=$1
SAMPLENAME=$HOME/~webdavhelpersample.$EXTENSION
touch $SAMPLENAME
CURMINE=$(xdg-mime query filetype $SAMPLENAME)
rm $SAMPLENAME
CURDSK=$(xdg-mime query default $CURMINE)
if [ -f /.local/share/applications/$CURDSK ]; then
TRUEDSK=/.local/share/applications/$CURDSK
elif [ -f /usr/local/share/applications/$CURDSK ]; then
TRUEDSK=/usr/local/share/applications/$CURDSK
elif [ -f /usr/share/applications/$CURDSK ]; then
TRUEDSK=/usr/share/applications/$CURDSK
else
echo "Sorry no executable found for $1"
exit 1
fi
WHATTODO=$(grep "^Exec" $TRUEDSK | head -1)
echo $WHATTODO
Once we figured that there are only 3 locations for the desktop files it was not hard anymore.