Skip to content

Instantly share code, notes, and snippets.

@PowerBall253
Last active September 25, 2023 09:01
  • Star 86 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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

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

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

@DartMitai
Copy link

DartMitai 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

@CRAG666
Copy link

CRAG666 commented Jul 24, 2023

@radholm I have the same error but still can't solve it

@mischw
Copy link

mischw commented Aug 11, 2023

Another reason which might prevent screensharing from working is the monitor using 10 bit depth. As soon as I switched back to 8 bit it worked.
hyprwm/xdg-desktop-portal-hyprland#24

@univeous
Copy link

I'm still getting xdg-desktop-portal-hyprland: unsupported wl_shm format 0x343247 error even with hyprland-nvidia-git.
I followed all the steps in this guide and the hyprland wiki. Does anyone have any clue?

@hammsvietro
Copy link

same issue here

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