Bug 399380 - XDG Portal support for KRun
Summary: XDG Portal support for KRun
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-04 15:06 UTC by Daniel Vrátil
Modified: 2019-02-21 20:16 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Vrátil 2018-10-04 15:06:49 UTC
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.
Comment 1 Daniel Vrátil 2018-10-04 15:08:08 UTC
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.
Comment 2 Jan Grulich 2018-10-05 05:35:40 UTC
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
Comment 3 Nate Graham 2019-02-21 20:16:19 UTC
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