Hi, I have a little project with a tray indicator icon menu item that relies on xdg-open
to open a folder location for the user. This almost always works as long as the xdg-mime
setting for the default app to handle inode/directory
is correct.
In Leap 16 beta it doesn’t work on Plasma 6. And I know why.
The xdg-open
command is actually just a long shell script with functions like this:
open_kde()
{
if [ -n "${KDE_SESSION_VERSION}" ]; then
case "${KDE_SESSION_VERSION}" in
4)
kde-open "$1"
;;
5)
"kde-open${KDE_SESSION_VERSION}" "$1"
;;
6)
kde-open "$1"
;;
esac
else
kfmclient exec "$1"
kfmclient_fix_exit_code $?
fi
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
}
This is the current version of the relevant function in the script hosted at the source:
Over a year ago, when Plasma 6 was still in beta/prerelease, most distros already had the xdg-open
command updated to handle Plasma 6, while a few still had an older version of the script that only knew about Plasma 4 and 5, like this:
open_kde()
{
if [ -n "${KDE_SESSION_VERSION}" ]; then
case "${KDE_SESSION_VERSION}" in
4)
kde-open "$1"
;;
5)
"kde-open${KDE_SESSION_VERSION}" "$1"
;;
esac
else
kfmclient exec "$1"
kfmclient_fix_exit_code $?
fi
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
}
KDE Neon was strangely one of the distros that hadn’t updated the script version yet. The function looks the same in the version of the script on Leap 16 beta.
The script in either case has the defect that if KDE_SESSION_VERSION
is found but the value is not in the case
logic tree, it will simply do nothing, with no error message and no bad return code. This can cause a lot of confusion for the user wondering why it isn’t doing anything. I was able to implement a fall-back mechanism in my app so that it will work on Leap 16 even before xdg-open
gets updated, but most users may find it difficult to figure out why the command is not working in Plasma 6.
I don’t have an account on the openSUSE Bugzilla, and don’t really have a reason to be signing up for one. Leap 16 is just one of many distros I test my project on. If someone who has a Bugzilla account could report this and help prompt the xdg-utils
package to be updated, so that xdg-open
will function in Plasma 6 (which is available on Leap 16 beta), that would be appreciated.
I have separately submitted an issue for xdg-utils
at the source, to possibly get the open_kde()
function updated with some error messages and fall-back actions for any future unrecognized values of KDE_SESSION_VERSION
, which would prevent issues like this.
Not sure if this is the right forum to post this in, but I’m sure it will get moved if not. There’s no leap-16 tag, so I’m using “other”.
Thanks.