I remember some time ago I, too, had some trouble with mimetypes and files being opened by the wrong apps. Although I do not use KDE I will still share the experience, it might be at least partially applicable or may give you some new ideas. To keep things simple I will only consider
/usr/share/applications as the location that is processed. All that is said may apply (in part) to other locations such as
/usr/local or
$HOME/.local.
Quote:
Originally Posted by bassmadrigal
I think the only option for packagers would be to query the MIME database for any supported file associations before running the commands in the doinst.sh and then reset any changed MIME types
|
This might not work. The app that opens the file is determined by the script
/usr/share/xdg-mime. Here is the code that determines which application KDE uses for the mimetype:
Code:
defapp_kde()
{
MIME="$1"
if [ -n "${KDE_SESSION_VERSION}" ]; then
case "${KDE_SESSION_VERSION}" in
4)
KTRADER=`which ktraderclient 2> /dev/null`
MIMETYPE="--mimetype"
SERVICETYPE="--servicetype"
;;
5)
KTRADER=`which ktraderclient${KDE_SESSION_VERSION} 2> /dev/null`
MIMETYPE="--mimetype"
SERVICETYPE="--servicetype"
;;
esac
else
...
defapp_generic "$1"
fi
}
KDE 4/5 uses
ktraderclient to determine the application that processes the mimetype. As you can see, this branch is only entered when
$KDE_SESSION_VERSION is set. This variable may not be set when you install as
root. So the script will call the
defapp_generic() function:
Code:
defapp_generic() {
...
for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
for prefix in "$XDG_MENU_PREFIX" ""; do
DEBUG 2 "Checking $x/applications/${prefix}defaults.list and $x/applications/${prefix}mimeinfo.cache"
trader_result=`grep "$MIME=" $x/applications/${prefix}defaults.list $x/ap plications/${prefix}mimeinfo.cache 2> /dev/null | head -n 1 | cut -d '=' -f 2 | cut -d ';' -f 1`
if [ -n "$trader_result" ] ; then
echo $trader_result
exit_success
fi
done
done
defapp_fallback $MIME
exit_success
}
I left out the part that process the file
mimeapps.list since it is not present in Slackware 14.2. Emphasized in bold are two other lists that are processed in
/usr/share/applications:
defaults.list and
mimeinfo.cache.
KDE may also have them as
kde-defaults.list and
kde-mimeinfo.cache, I am not sure about that.
If no hit is found in those lists then the script will call
defapp_fallback(). This function will search all
*.desktop files in
/usr/share/applications for the mimetype. A desktop file may define its own priority, however, none of my
*.desktop files do that on my 14.2 install. At this point it selects the first hit.
As I said, I do not use KDE and I do not know how
ktraderclient determines the application for the mimetype, it may take aforementioned lists and
*.desktop files into consideration.
So my suggestion would be to look in the source of your package and see if it installs a
*.desktop file. It might be as "easy" as simply preventing it from installing that
*.desktop file. Or install it as
*.desktop.void, this way it would still be there as template. If someone wants to use 'mediainfo/picard/easytag' as default app then he would not have to recreate it from scratch. But those are just guesses, the different processes for different DEs certainly complicate things.
Hope this helps.