KRun can invoke an application based on default handler for given mimetype or URI, or show a dialog for user to choose which application should be used to open the file. This of course does not work inside of Flatpak, because there's nothing but the app itself, so opening http URLs for instance does not work. KRun should be made aware of Flatpaks and delegate it's entire functionality to the Portal in such case.
CC'ing Jan, since he's the xdg-desktop-portal-kde maintainer. I noticed that the portal already has the same functionality as KRun (or maybe it could be ported to use KRun itself), but generally the app-choosing part is already there.
Hi, support for portals in KRun can be done the same way like it's implemented in Qt, which can be found here [1]. I'm not sure about using KRun directly in xdg-desktop-portal-kde, the portal backend basically is supposed to just show list of applications (that's why it's called AppChooser) and return the result back to xdg-desktop-portal which will open the app for us. I can look into supporting portals in KRun myself if nobody will do it till when I find time to do so. [1] - https://code.woboq.org/qt5/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp.html
Git commit c063b1ce848987c9d236d6ec3d9cf4f8c5f11627 by Nate Graham, on behalf of Denis Karpovskiy. Committed on 21/02/2019 at 20:16. Pushed by ngraham into branch 'master'. Add support for portals in KRun Summary: Currently KRun in Flatpak/Snap doesn't support portals so it can't launch an application for a given url (because it can't break through sandbox). This patch allows KRun to use portals to pass the url through sandbox. QDesktopServices::openUrl handles that case and sends appropriate DBus calls to portals, so URIs will be proccessed accordingly by host system. Test Plan: I couldn't build KIO from master in current flatpak KDE runtime (even without the patch), so here are commands to test the patch on top of KIO 5.54.1: 1. Install org.kde.Sdk 5.12 from flathub 2. Install org.kde.konversation from KDE Nightly flatpak repo (https://community.kde.org/Guidelines_and_HOWTOs/Flatpak) 3. Apply the patch to KIO 5.54.1 4. run 'flatpak run --filesystem=host --command=sh --devel org.kde.Sdk//5.12' to enter SDK 5. build KIO 6. exit SDK (exit or Ctrl+D) 7. run flatpak shell with Konversation 'flatpak run --filesystem=host --command=sh org.kde.konversation' 8. run LD_PRELOAD="path/to/libKF5KIOCore.so path/top/libKF5KIOWidgets.so path/to/libKF5KIOFileWidgets.so" /app/bin/konversation to run it with just compiled KIO (the compiled libraries are located in bin directory inside your build directory) Now link clicks should pass sandbox and do the appropriate actions (open browser for http links, email application for mailto links, file manager for file://...) Reviewers: jgrulich, apol, dfaure, #frameworks Reviewed By: apol Subscribers: ngraham, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D18762 M +18 -3 src/widgets/krun.cpp M +2 -0 src/widgets/krun_p.h https://commits.kde.org/kio/c063b1ce848987c9d236d6ec3d9cf4f8c5f11627