Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Screen sharing on Hyprland (Arch Linux)

Screen sharing on Hyprland (Arch Linux)

Table of contents

Introduction

This guide will go through the setup and troubleshooting steps required to get screen sharing working on OBS with the Hyprland compositor.

This guide will use the yay AUR helper for AUR package installation, but the commands should be similar for other helpers such as paru.

WARNING: This guide demands that the user has a basic understanding on installing packages (both official and AUR), using git, compiling from source, and some patience.

Install PipeWire and friends

First, we need to install pipewire and wireplumber. To do that, run the following command:

sudo pacman -S pipewire wireplumber

Install xdg-desktop-portal and friends

Option #1: xdg-desktop-portal-hyprland (recommended)

We will install the xdg-desktop-portal-hyprland-git package from the AUR, which provides additional functionality such as window sharing. With an AUR helper such as yay, you can install it this way:

yay -S xdg-desktop-portal-hyprland-git

Option #2: xdg-desktop-portal-wlr (not recommended)

This option provides less options than xdg-desktop-portal-wlr, but it will still allow fullscreen sharing. Install it running the following command:

sudo pacman -S xdg-desktop-portal-wlr

WARNING: The rest of this guide will assume xdg-desktop-portal-hyprland was choosed. If you picked this option, replace any -hyprland mentions for -wlr in the rest of this guide.

Remove other portal implementations

Make sure you don't have any other xdg-desktop-portal-* packages installed (except possibly xdg-desktop-portal-gtk for file dialogs), as this could cause problems later. To check if you have any, run the following command:

pacman -Q | grep xdg-desktop-portal-

then delete all of the listed packages except the -hyprland one we just installed and the -gtk one if you so chose.

Also make sure to install the optional dependencies grim and slurp:

sudo pacman -S grim slurp

Editing the configuration file

Open your Hyprland config file (usually located at ~/.config/hypr/hyprland.conf) with a text editor, and add the following line at the end:

exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP

This will make sure that xdg-desktop-portal-hyprland can get the required variables on startup.

Restart your session

Now log out and then log back in, or reboot your system. Once you're back into Hyprland, try sharing in OBS with the "Screen Capture (PipeWire)" option.

If it works, congratulations! You may exit this guide now. If not, follow along:

Troubleshooting PipeWire

Make sure both pipewire and wireplumber are running. Run the following command:

systemctl --user status pipewire wireplumber

This should return "active (running)" for both. If it doesn't, follow the Arch Wiki article for troubleshooting.

Troubleshooting desktop portal

Run the following command to check for errors in xdg-desktop-portal-hyprland:

systemctl --user status xdg-desktop-portal-hyprland

This should return "active (running)". If it doesn't, check the errors it gives you. Here's some workarounds for common errors:

Portal service (wlroots implementation) was skipped because of a failed condition check

Make sure you added the required line to the Hyprland configuration. Check for typos.

unsupported wl_shm format 0x34324742 (after trying to share the screen on NVIDIA)

Install the modified hyprland-nvidia-git AUR package:

yay -S hyprland-nvidia-git

Alternatively, you can modify the source code manually:

We'll need to modify the wlroots submodule source code to make it choose a viable format.

First, clone the Hyprland repo if you haven't already:

git clone --recursive https://github.com/vaxerski/Hyprland

Then, install all required dependencies for building, as specified in the wiki:

sudo pacman -S gdb ninja gcc cmake libxcb xcb-proto xcb-util xcb-util-keysyms libxfixes libx11 libxcomposite xorg-xinput libxrender pixman wayland-protocols cairo pango --needed

Open the wlroots/types/output/render.c file, look for the wlr_output_preferred_read_format, and replace it with the following:

uint32_t wlr_output_preferred_read_format(struct wlr_output *output) {
    return DRM_FORMAT_XRGB8888;
}

Afterwards, compile and install by running sudo make install, then restart your session.

Troubleshooting OBS

You can try the wlrobs-hg plugin.

Troubleshooting your browser

If you're trying to share your screen in your browser, first make sure that it supports Wayland and screen sharing on it, else it will not work.

Firefox

Make sure you're running on Wayland. To do this, go to about:support, look for "Window Protocol", and make sure it is set to "wayland". If it isn't, set the environment variable MOZ_ENABLE_WAYLAND=1 in an environment file, like /etc/environment, /etc/profile, ~/.bash_profile, ~/.zshenv, etc.

If it still doesn't work, open about:config and make sure the media.peerconnection.enabled flag is set to true.

Chromium

To run on Wayland, set the --ozone-platform-hint=auto flag in the chromium flags file (~/.config/chromium-flags.conf for the default package, ~/.config/chrome-flags.conf for Chrome).

Also ensure the "WebRTC PipeWire support" flag is enabled by opening chrome://flags/#enable-webrtc-pipewire-capturer and enabling it.

Troubleshooting your app

Make sure the app you're trying to share the screen with supports Wayland and sharing the screen with it.

Notable programs that still don't have full support for this are Discord and Zoom.

It still doesn't work!

Follow the official xdg-desktop-portal-wlr troubleshooting guide.

If it still doesn't work, consider opening an issue in the xdg-desktop-portal-hyprland repo.

References

@ribosomerocker
Copy link

ribosomerocker commented Oct 14, 2022

@danielgafni @EysseW If you're willing to use Discord, I suggest joining the Discord server to ask for help. It should be linked somewhere on the Hyprland page or GitHub.

@danielgafni
Copy link

To anyone reading this: the wlrobs-hg is a great solution! It solved everything for OBS immediately.

@EysseW
Copy link

EysseW commented Oct 19, 2022

I have asked for help there, with no succes. I am pretty lost at this point.

@ThatOneCalculator
Copy link

To anyone reading this: the wlrobs-hg is a great solution! It solved everything for OBS immediately.

Bumping this as that's the only thing that helped me

@EysseW
Copy link

EysseW commented Oct 25, 2022

Revisited this stuff, checked everything, tried wlrobs, still no luck. Any ideas?
So the issue I am having is not that I don't have the screens to screenshare from, it's that they are completely black, except for the cursor.

@Korazza
Copy link

Korazza commented Oct 28, 2022

hyprland-nvidia-git AUR package now embeds the screenshare patch, and it works perfectly fine. You should update the hyprland-nvidia-screenshare-git since it no longer works.

@EysseW
Copy link

EysseW commented Oct 28, 2022

I don't use nvidia.

@PowerBall253
Copy link
Author

I've added the hyprland-nvidia-git package and the wlrobs-hg plugin for OBS. Thank you!

@875d
Copy link

875d commented Nov 27, 2022

Screen sharing on OBS works, but not with Firefox nor Chromium. Those share a black screen.

I have NVIDIA proprietary drivers, and a laptop with an external monitor. I went through all the checks here as well as all the checks in the linked xdg-desktop-portal-wlr troubleshooting guide. All seems fine.

And I have the hyprland-nvidia-git AUR package (that's why the OBS screensharing works).

What can I do to pin down the issue? Any suggestions?

@imhemish
Copy link

imhemish commented Dec 3, 2022

Another thing to notice, XDG_CURRENT_DESKTOP should be set to 'Hyprland' (case sensitive) because it is named as such at https://github.com/emersion/xdg-desktop-portal-wlr/blob/master/wlr.portal, in the case of Sway, it should be 'sway' (case sensitive)

@EysseW
Copy link

EysseW commented Dec 7, 2022

So according to the hyprland dev, x Wayland apps can't screenshare Wayland stuff. This explains all my problems.

@imhemish
Copy link

imhemish commented Dec 8, 2022

Screen sharing on OBS works, but not with Firefox nor Chromium. Those share a black screen.

I have NVIDIA proprietary drivers, and a laptop with an external monitor. I went through all the checks here as well as all the checks in the linked xdg-desktop-portal-wlr troubleshooting guide. All seems fine.

And I have the hyprland-nvidia-git AUR package (that's why the OBS screensharing works).

What can I do to pin down the issue? Any suggestions?

Run firefox and chromium in Wayland mode

@JohnOberhauser
Copy link

JohnOberhauser commented Dec 9, 2022

When I remove the other xdg-desktop-portal backends (gtk and gnome) I lose some functionality elsewhere because xdg-desktop-portal-wrl only implements the Screencast and Screenshot APIs. But with them installed, xdg-desktop-portal uses gtk/gnome for screenshot and screencast. Do you know of a way to force wrl to be the default for the APIs it implements, and fallback to gtk/gnome for the rest?

Edit: I ended up uninstalling xdg-desktop-portal-gnome, but I kept xdg-desktop-portal-gtk (and of course have xdg-desktop-portal-wlr installed). With that I'm able to screencast and as far as I can tell, the functionality that was missing for me has returned. (The functionality that was missing for me was not being able to click and open links into my browser from flatpak apps like slack)

If for some reason things get a little wonky with screenshots / screencasts, I might end up forking xdg-desktop-portal-gtk and just disable the screencast stuff.

I suggest adding a note in the section where you ask people to uninstall other xdg-desktop-portal backends to say that wrl only implements screencast and screenshot, and some functionality will be missing if there isn't another backend installed.

@danielgafni
Copy link

Just a heads up - Hyprland's own desktop portal was released and has more features like screensharing any window!

Here are the docs.

paru -S xdg-desktop-portal-hyprland-git

@ToMattBan
Copy link

ToMattBan commented Dec 15, 2022

So, I manage to make this work (screensharing on Chrome and Firefox) , I'm not sure about what I did, but I think that what helped me was:

This https://gist.github.com/PowerBall253/2dea6ddf6974ba4e5d26c3139ffb7580#editing-the-configuration-file

Then install xdg-desktop-portal-hyprland-git like Daniel said here https://gist.github.com/PowerBall253/2dea6ddf6974ba4e5d26c3139ffb7580?permalink_comment_id=4402042#gistcomment-4402042

Then I uninstalled all others xdg-desktop-portal (gtk and wlr)

Went to chrome, opened chrome://flags and setted:
WebRTC PipeWire support to Enabled
Preferred Ozone platform to Wayland

Now, everything works well, make sure to restart the browser

@EysseW
Copy link

EysseW commented Dec 19, 2022

Works like a charm! Does anyone know a way to make this work in native discord client as well?

@kstepanovdev
Copy link

kstepanovdev commented Jan 31, 2023

I've bumped into a strange situation.

  1. I did everything from the guide (except for the part with XDPW. I use XDPH).
  2. All required services like Pipewire, Wireplumber, xdg-desktop-portal work.
  3. Screensharing works on sway, but it doesn't work in Hyprland itself.

Any ideas on what can I check or fix additionally? Because I've run out of options.

@hyper-dot
Copy link

hyper-dot commented Feb 2, 2023

I followed the guide. OBS works perfectly but when I try to share screen in browser and discord it doesn't work. Anyone have the same issue?

Edit : I found that it's google-chrome's and discord's issue. I can share screens in firefox.

@kstepanovdev
Copy link

I followed the guide. OBS works perfectly but when I try to share screen in browser and discord it doesn't work. Anyone have the same issue?

Edit : I found that it's google-chrome's and discord's issue. I can share screens in firefox.

AFAIK you can share screen in chromium, but you need to enable related flags in config.

@EysseW
Copy link

EysseW commented Feb 2, 2023

So, for discord, I found the webcord client is the solution. Screensharing entire screens works there. It's also got some neat little built in other features. Worth to take a look at!

@hyper-dot
Copy link

I followed the guide. OBS works perfectly but when I try to share screen in browser and discord it doesn't work. Anyone have the same issue?
Edit : I found that it's google-chrome's and discord's issue. I can share screens in firefox.

AFAIK you can share screen in chromium, but you need to enable related flags in config.

I didn't get it. What flags. Can you explain in brief ? will be really helpful.

@kstepanovdev
Copy link

kstepanovdev commented Feb 3, 2023

I followed the guide. OBS works perfectly but when I try to share screen in browser and discord it doesn't work. Anyone have the same issue?
Edit : I found that it's google-chrome's and discord's issue. I can share screens in firefox.

AFAIK you can share screen in chromium, but you need to enable related flags in config.

I didn't get it. What flags. Can you explain in brief ? will be really helpful.

I meant this.
chrome://flags/#enable-webrtc-pipewire-capturer

@hyper-dot
Copy link

I followed the guide. OBS works perfectly but when I try to share screen in browser and discord it doesn't work. Anyone have the same issue?
Edit : I found that it's google-chrome's and discord's issue. I can share screens in firefox.

AFAIK you can share screen in chromium, but you need to enable related flags in config.

I didn't get it. What flags. Can you explain in brief ? will be really helpful.

I meant this. chrome://flags/#enable-webrtc-pipewire-capturer

Thank you worked like charm !! 😍

@mamaraddio
Copy link

My rig:

OS: Arch Linux x86_64
Host: 81LK (IdeaPad L340-15IRH Gaming)
Kernel: 6.1.10-arch1-1
Display: 1920x1080 @ 60Hz
WM: Hyprland (Wayland)
CPU: Intel(R) Core(TM) i7-9750HF (12) @ 4.5 GHz
GPU: NVIDIA GeForce GTX 1650 Mobile / Max-Q

I followed step by step the Hyprlan Wiki, then I noticed that my setup was unable to screenshare and thanks to Hyprland Wiki reference I found this gist. I read and closely followed this guide.

Now I am able to capture the screen on OBS.

I use Brave, therefore a Chromium based browser, I setted the two flags for WebRTC and ozonePlatform and I tried a screenshare on Google Meet.
Despite of what Hyprland Wiki says, I can share single browser tabs and single windows, but I can't share entire monitor.

I installed nvidia-open-dkms drivers, slurp, grim, and done all the NVIDIA tricks referenced betwen Hyprland Wiki, NVIDIA docs, this guide and the Archwiki, including kernel parameters.

Every time i try to share the entire screen I get a black screen sharing.

Below the packages I installed (hope to don't forget nothing usefull)

paru -Qs nvidia
local/egl-wayland 2:1.1.11-3
    EGLStream-based Wayland external platform
local/hyprland-nvidia-git r2433.287f3132-1
    A dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks. (NVIDIA patch)
local/lib32-nvidia-utils 525.89.02-1
    NVIDIA drivers utilities (32-bit)
local/libvdpau 1.5-1
    Nvidia VDPAU library
local/libxnvctrl 525.85.05-1
    NVIDIA NV-CONTROL X extension
local/nvidia-open-dkms 525.89.02-2
    NVIDIA open kernel modules
local/nvidia-settings 525.85.05-1
    Tool for configuring the NVIDIA graphics driver
local/nvidia-utils 525.89.02-1
    NVIDIA drivers utilities
local/nvidia-vaapi-driver-git 0.0.8.r63.g766d843-1
    A VA-API implemention using NVIDIA's NVDEC

paru -Qs qt.-wayland
local/qt5-wayland 5.15.8+kde+r58-1 (qt qt5)
    Provides APIs for Wayland
local/qt6-wayland 6.4.2-1 (qt6)
    Provides APIs for Wayland

paru -Qs hyprland
local/hyprland-nvidia-git r2433.287f3132-1
    A dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks. (NVIDIA patch)
local/waybar-hyprland-git 0.9.17.r66.gea38eec2-1
    Highly customizable Wayland bar for Sway and Wlroots based compositors, with workspaces support for Hyprland (git version)
local/xdg-desktop-portal-hyprland-git r258.2fa7e34-1
    xdg-desktop-portal backend for hyprland
    
paru -Qs obs
local/obs-studio 29.0.2-1
    Free, open source software for live streaming and recording
local/wlrobs-hg r63.a48763b63f96-1
    An obs-studio plugin that allows you to screen capture on wlroots based wayland compositors

@MitaiDart
Copy link

systemctl --user status pipewire wireplumber

● pipewire.service - PipeWire Multimedia Service
     Loaded: loaded (/usr/lib/systemd/user/pipewire.service; enabled; preset: enabled)
     Active: active (running) since Mon 2023-03-13 22:52:03 +05; 23min ago
TriggeredBy: ● pipewire.socket
   Main PID: 612 (pipewire)
      Tasks: 2 (limit: 14040)
     Memory: 8.0M
        CPU: 316ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/pipewire.service
             └─612 /usr/bin/pipewire

мар 13 22:52:03 dart systemd[605]: Started pipewire.service - PipeWire Multimedia Service.
мар 13 22:52:03 dart pipewire[612]: mod.rt: Can't find org.freedesktop.portal.Desktop. Is xdg-desktop-portal running?
мар 13 22:52:03 dart pipewire[612]: mod.rt: found session bus but no portal

● wireplumber.service - Multimedia Service Session Manager
     Loaded: loaded (/usr/lib/systemd/user/wireplumber.service; enabled; preset: enabled)
     Active: active (running) since Mon 2023-03-13 22:52:03 +05; 23min ago
   Main PID: 613 (wireplumber)
      Tasks: 4 (limit: 14040)
     Memory: 36.3M
        CPU: 387ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/wireplumber.service
             └─613 /usr/bin/wireplumber

мар 13 22:52:03 dart systemd[605]: Started wireplumber.service - Multimedia Service Session Manager.
мар 13 22:52:03 dart wireplumber[613]: Can't find org.freedesktop.portal.Desktop. Is xdg-desktop-portal running?
мар 13 22:52:03 dart wireplumber[613]: found session bus but no portal
мар 13 22:52:05 dart wireplumber[613]: Failed to set scheduler settings: Операция не позволена
мар 13 22:52:05 dart wireplumber[613]: SPA handle 'api.libcamera.enum.manager' could not be loaded; is it installed?
мар 13 22:52:05 dart wireplumber[613]: PipeWire's libcamera SPA missing or broken. libcamera not supported.
мар 13 22:52:05 dart wireplumber[613]: SPA handle 'api.bluez5.enum.dbus' could not be loaded; is it installed?
мар 13 22:52:05 dart wireplumber[613]: PipeWire's BlueZ SPA missing or broken. Bluetooth not supported.

systemctl --user status xdg-desktop-portal-hyprland

● xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-hyprland.service; static)
     Active: active (running) since Mon 2023-03-13 22:52:35 +05; 24min ago
   Main PID: 860 (xdg-desktop-por)
      Tasks: 2 (limit: 14040)
     Memory: 1.6M
        CPU: 19ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal-hyprland.service
             └─860 /usr/libexec/xdg-desktop-portal-hyprland

мар 13 22:52:35 dart systemd[605]: Starting xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation)...
мар 13 22:52:35 dart systemd[605]: Started xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation).

systemctl --user status xdg-desktop-portal

● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
     Active: active (running) since Mon 2023-03-13 22:52:35 +05; 24min ago
   Main PID: 817 (xdg-desktop-por)
      Tasks: 4 (limit: 14040)
     Memory: 9.4M
        CPU: 55ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/xdg-desktop-portal.service
             └─817 /usr/libexec/xdg-desktop-portal

мар 13 22:52:33 dart systemd[605]: Starting xdg-desktop-portal.service - Portal service...
мар 13 22:52:34 dart xdg-desktop-por[817]: No skeleton to export
мар 13 22:52:35 dart systemd[605]: Started xdg-desktop-portal.service - Portal service.

OBS not work and my browaser on unfolds on a full window crashes, where should I write to get help setting up?))

@PowerBall253
Copy link
Author

@MitaiDart Do you happen to have any other portal implementations installed? Run pacman -Q | grep xdg-desktop-portal- to check.

@MitaiDart
Copy link

MitaiDart commented Mar 14, 2023

@MitaiDart Do you happen to have any other portal implementations installed? Run pacman -Q | grep xdg-desktop-portal- to check.

sudo apt list --installed | grep xdg-desktop-portal
xdg-desktop-portal-gtk/testing,now 1.14.1-1 amd64 [установлен]
xdg-desktop-portal/testing,now 1.16.0-2 amd64 [установлен]

this question is not entirely clear to me if I delete everything including xdg-desktop-portal-gtk abd xdg-desktop-portal then the status becomes like this

systemctl --user status xdg-desktop-portal-hyprland
○ xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-hyprland.service; static)
     Active: inactive (dead)

@rileyhawk1417
Copy link

@MitaiDart am also experiencing a similar issue. Pipewire & Wireplumber can find a session but not the bus xdg-desktop-portal not sure why its not detecting xdg-desktop-portal-hyprland. I also followed this message and enabled WebRTC PipeWire support to Enabled & Preferred Ozone platform to wayland.
Can only share single tabs, but not a window or the entire screen. Was testing screen sharing on brave using google meet.

@hyper-dot
Copy link

@MitaiDart am also experiencing a similar issue. Pipewire & Wireplumber can find a session but not the bus xdg-desktop-portal not sure why its not detecting xdg-desktop-portal-hyprland. I also followed this message and enabled WebRTC PipeWire support to Enabled & Preferred Ozone platform to wayland. Can only share single tabs, but not a window or the entire screen. Was testing screen sharing on brave using google meet.

https://gist.github.com/PowerBall253/2dea6ddf6974ba4e5d26c3139ffb7580?permalink_comment_id=4458701#gistcomment-4458701

Check this out!!

@radholm
Copy link

radholm commented May 11, 2023

Im on:
hyprland-nvidia-git r2895.7fde80f3-1
hyprland-scratchpad-git 814e260-1
waybar-hyprland-git 0.9.17.r159.ga9a22234-1
xdg-desktop-portal-hyprland-git 1:r282.2bdadd2-1
vivaldi 6.0.2979.18-1

The screensharing with Vivaldi worked fine until like a week ago, can't tell what happened. I have enabled WebRTC in the browser and tried with x11 and wayland as the Ozone flag.

Logs

This happens when trying to select entire screen (previewer is black).

journalctl --user --user-unit wireplumber.service -f:

<WpPortalPermissionStorePlugin:0x55f5181f02e0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment