Solution to the problem of screen recording failure under independent window manager

I have been using Labwc, a Wayland window manager, for a long time. I first used it in the Ubuntu environment of my company's computers, and later I built a mini host and switched to using it under Arch.

Overall, I have almost created a desktop environment that suits me, which is much more controllable than using behemoths such as Gnome and KDE directly. For example, pressing Win + Enter can pop up the terminal at any time, and Win + H can hide it. It's so cool that my efficiency has soared.

Each desktop core component is carefully selected by myself, and the configuration file github dotfiles is managed. If the computer breaks down, you can reinstall it at any time to return to the familiar environment.

The mini host has AMD's integrated graphics, so there is no problem playing Dota2 and CS2.

Everything looks good, but...

One night, when I was solving a problem with my company partner, the other party wanted to see my terminal real-time operation, and needed to use the screen sharing function under Feishu. After opening the sharing, the trouble appeared, and the other party reported that they could only see a black screen.

The incident happened suddenly, and I didn't expect it to happen. I have never tested the screen sharing function in the Labwc + Arch environment. It was a blow to the head. I couldn't delay making money. Finally, I used the rear camera of the mobile phone to record the screen to solve it. Either the camera was not aligned or the light was too dark. The process was painful.

Later, one weekend, when I was playing Dota2, I encountered a bug that the system automatically sold the shoes after the gun bought them. At that time, I downloaded the game recording screen to share, opened OBS, and found that the screen recording could not be used.

It can be seen that there is still a demand for real-time screen sharing, or live broadcasting, and this problem must be solved. When you search online, there is less relevant information, and you can't even figure out which component is wrong.

The problem is very niche:

  • There are few Linux users;
  • There are even fewer Linux users who use independent window managers;
  • There are even fewer users who meet the above two conditions and also have screen sharing needs.

1. Solution

The solution is very simple. Install the xdg-desktop-portal related packages:

1sudo pacman -S xdg-desktop-portal
2sudo pacman -S xdg-desktop-portal-wlr

xdg-desktop-portal-wlr is a backend implementation of xdg-desktop-portal. When you use the mature desktop environment Gnome/KED, xdg-desktop-portal-gnome and xdg-desktop-portal-kde have already been automatically pre-installed for you.

Because Labwc is an independent window manager, it does not include xdg-desktop-portal-wlr by default, so the screen will be black or the live broadcast will not be possible. Screen sharing in the Wayland environment is generally done through Pipewire, calling xdg-desktop-portal, which then calls the xdg-desktop-portal backend of the current DE environment to complete the entire link. Different desktop environments have different backend implementations, refer to this list

1➜ ~ echo $XDG_CURRENT_DESKTOP
2wlroots

From the above environment variable output, it can be inferred that the backend implementation corresponding to wlroots is xdg-desktop-portal-wlr, so this package needs to be installed additionally.

 1➜ ~ ls -al /usr/share/xdg-desktop-portal
 2total 20
 3drwxr-xr-x 1 root root 190 Jun 10 12:13 ./
 4drwxr-xr-x 1 root root 5018 Jun 12 12:36 ../
 5-rw-r--r-- 1 root root 24 Mar 24 10:58 gtk-portals.conf
 6-rw-r--r-- 1 root root 32 May 9 04:32 hyprland-portals.conf
 7-rw-r--r-- 1 root root 67 May 22 16:03 labwc-portals.conf
 8drwxr-xr-x 1 root root 68 Jun 7 11:22 portals/
 9-rw-r--r-- 1 root root 423 Jun 9 07:51 sway-portals.conf
10-rw-r--r-- 1 root root 24 Aug 9 2024 wlr-portals.conf
11➜ ~ ls -al /usr/share/xdg-desktop-portal/labwc-portals.conf
12-rw-r--r-- 1 root root 67 May 22 16:03 /usr/share/xdg-desktop-portal/labwc-portals.conf
13➜ ~ ls -al /usr/share/xdg-desktop-portal
14total 20
15drwxr-xr-x 1 root root 190 Jun 10 12:13 ./
16drwxr-xr-x 1 root root 5018 Jun 12 12:36 ../
17-rw-r--r-- 1 root root 24 Mar 24 10:58 gtk-portals.conf
18-rw-r--r-- 1 root root 32 May 9 04:32 hyprland-portals.conf
19-rw-r--r-- 1 root root 67 May 22 16:03 labwc-portals.conf
20drwxr-xr-x 1 root root 68 Jun 7 11:22 portals/
21-rw-r--r-- 1 root root 423 Jun 9 07:51 sway-portals.conf
22-rw-r--r-- 1 root root 24 Aug 9 2024 wlr-portals.conf
23➜ ~ cat /usr/share/xdg-desktop-portal/labwc-portals.conf
24[preferred]
25default=wlr;*
26org.freedesktop.impl.portal.Inhibit=none
27➜ ~ cat /usr/share/xdg-desktop-portal/sway-portals.conf
28[preferred]
29default=gtk
30org.freedesktop.impl.portal.ScreenCast=wlr
31org.freedesktop.impl.portal.Screenshot=wlr
32# xdg-desktop-portal-gtk's implementation uses org.gnome.SessionManager and
33# org.freedesktop.ScreenSaver, neither of which is implemented by Sway. This
34# will cause some programs (e.g. Firefox) to use Wayland's idle-inhibit
35# protocol instead, which sway does implement.
36org.freedesktop.impl.portal.Inhibit=none

You can read the arch documentation. The XDG_CURRENT_DESKTOP environment variable determines which configuration file to read, and the configuration file controls which backend implementation to use. The file does not need to be configured independently. After the package is installed, it will be automatically processed. If you understand more, you will learn some corner knowledge.

What is XDG Desktop Portal

The AI ​​related introduction is as follows:

1XDG Desktop Portal is a core component of the Flatpak ecosystem in the field of Linux development. It provides a secure and unified way for applications to access system resources, such as file selectors, screenshot tools, printing services, etc.
2
3Security: Based on the D-Bus protocol, it provides an interface in a sandbox environment, allowing Flatpak applications to interact safely with the host operating system. Each request will be checked for permissions and requires explicit approval from the user to prevent unauthorized access.
4Unified interface: Developers can use the same API to implement various functions through XDG Desktop Portal without considering the differences in specific Linux distributions, which improves code portability and simplifies development work.
5Integration: It can seamlessly integrate with system-level services (such as file managers and printer settings), allowing applications to work like native applications without paying attention to the underlying implementation details.
6Bridging role: As a bridge between applications and desktop environments, it allows Flatpak applications to call system services, such as opening file dialog boxes or capturing screenshots, without directly interacting with the desktop environment, reducing coupling.
7Feature-rich: Supports file selection and saving, multimedia access, printing services, clipboard sharing, screenshots, and screen recording.
8Scalability and customizability: Designed with future expansion in mind, new portal services can be easily added. Different desktop environments can also provide their own implementations to maintain consistency in the desktop experience.
9Community support: XDG Desktop Portal is an open source project maintained and updated by an active community, which can continuously improve performance and stability.

Screenshots and screen recording are one of its functions.

XDG is the abbreviation of X Desktop Group. Although Wayland has become popular, it is estimated that the relevant name cannot be changed for historical reasons. I explain it separately because I am a Chinese user and it is difficult to remember.

Screenshot

obs-live

After installing the above packages, an option Screen Capture (PipeWire) will appear on OBS. Otherwise, it will not appear, and you will not be able to record the screen live.

On Feishu, I used the Linux desktop and mobile phone at the same time. There was no problem in testing screen sharing. I was too lazy to take screenshots; Tencent Conference did not test it because multiple terminals need to be registered for membership to participate in the meeting at the same time.

Lastmod: Wednesday, June 25, 2025

See Also:

Translations: