444. Portals and screen sharing
A portal is the desktop’s answer to a request an application cannot be trusted to carry out itself: open a file it was not given, show the screen, take a screenshot, read the colour scheme, open a link. On KDOS the portal front end, xdg-desktop-portal, passes every request to the KDE backend, which asks the person in a KDE dialog and has KWin capture the screen into PipeWire. This page covers the portal configuration, screenshots and recordings, sharing the screen with another application, sharing the whole desktop over VNC or RDP, and what a boxed application reaches through the portals. How the portals fit into the session is in Portals.
Installation
| Port | Provides |
|---|---|
| xdg-desktop-portal | The front end, org.freedesktop.portal.Desktop, and the permission store |
| xdg-desktop-portal-kde | The backend: the file chooser, screen cast, screenshot, remote desktop, settings, app chooser, notification, print, inhibit, global shortcuts and access dialogs |
| kwin | The screen and window capture the screen cast and screenshot draw on |
| kpipewire | Puts KWin’s capture into PipeWire streams |
| spectacle | Screenshots and screen recordings |
| krfb, krdp | Sharing the whole desktop over VNC and RDP |
| plasmoid-kdos-privacy | The privacy lamps, which show and stop every capture |
Neither portal is a service. The session bus starts both on the first request.
Configuration
Which backend answers
The front end reads kde-portals.conf, which plasma-workspace installs, because the session’s XDG_CURRENT_DESKTOP is KDE; it names the KDE backend for every interface. A file of your own in ~/.config/xdg-desktop-portal/ overrides it per interface (portals.conf(5)).
Which application is asking
Built without systemd, the front end names a caller’s application from the cgroup its process is in: the scope systemd’s naming would give it, app-<launcher>-<id>-<n>.scope. No caller is in one. A program Plasma or a terminal starts runs in the login’s own cgroup, and a box’s app-kdos-<box>-<n>.scope is never made, because elogind leaves /sys/fs/cgroup/<session>/cgroup.procs root’s. Every caller has the empty id, KDE’s dialogs ask for “an unidentifiable application”, and the permission store keeps one answer for all of them: a choice remembered for one program is the choice for every program and every box. Deleting the portal’s file under ~/.local/share/flatpak/db/ makes it ask again.
The capture keys
Print takes the whole screen, Shift+Print a rectangle, Meta+Shift+S a rectangle too, and Alt+Print, Meta+R or Meta+Shift+R record a rectangle, all in Spectacle; see Shortcuts and window rules.
Usage
Taking a screenshot or a recording
- Press one of the capture keys, or start Spectacle from Kickoff.
- Choose what to capture: the whole screen, the current screen, the active window or a rectangle; or switch to Recording.
- Spectacle shows the result, to annotate, copy, save or drag into another application.
From a terminal: spectacle -b -n -f -o ~/shot.png takes the whole screen with no window (-a the active window, -r a rectangle).
Sharing a screen or a window with an application
A browser, a video-call program or OBS Studio asks the ScreenCast portal. KDE’s dialog lists the screens and windows; pick one and Share. While it runs, the privacy lamp for the screen is lit in the system tray; a click on it stops every screen capture that can be stopped. The program receives a PipeWire stream and no access to the rest of the screen.
Sharing the whole desktop over VNC or RDP
Start Krfb (VNC) or turn on System Settings → Remote Desktop (RDP, krdp), and set a password. krdp is in the base the ISO carries; Krfb is not, and
sudo kdos update install krfbadds it.Open the port in the firewall:
kdos-power firewall vnc on # or: rdp onConnect from the other machine to port 5900 (VNC) or 3389 (RDP).
Close the port again with
kdos-power firewall vnc off.
Both serve the session through the RemoteDesktop and ScreenCast portals, so KWin asks before the first connection is let in.
Opening files from a boxed application
A boxed application’s Open and Save dialogs are the KDE file dialog, drawn outside the box. The portal hands a box, which is no Flatpak, the real path of the file you pick, and the box opens it through the home it shares; a box with home = private cannot reach a file the dialog picks outside it. The document portal’s own mount is not in a box: the portal mounts it for your user alone, and a box’s root, a subordinate uid, could not even stat it.
Tips
kdos privacylists what is capturing the microphone, the camera or the screen right now, and in which box.- GTK 4 applications use the portal file chooser by themselves, and GTK 3 ones that use GTK’s native chooser do because every login shell exports
GTK_USE_PORTAL=1; a GTK 3 application that builds GTK’s own dialog, such as GIMP, Inkscape or AbiWord, keeps it.
Troubleshooting
A request hangs or fails with no dialog. The backend did not start. Check from Konsole:
qdbus6 org.freedesktop.portal.Desktop
qdbus6 org.freedesktop.impl.portal.desktop.kde
Each lists its objects when it runs. Their output goes to the session bus’s log, $XDG_RUNTIME_DIR/ksvc/kdos-svc.dbus.log. A dialog whose QML import is missing does not open and the request fails; the log names the module.
A screen share shows a black picture. The program asked for a format KWin cannot give on software rendering, or for a window that was minimised. Share the screen instead of the window, or check qdbus6 org.kde.KWin /KWin supportInformation for the renderer.
A dialog names no application. cat /proc/<pid>/cgroup for the program shows where it is: 0::/<session>/session is the login’s own cgroup, from which the portal reads no id.
Known gaps
- Host applications and boxes reach the portals unidentified
- Known gaps: the desktop’s open items