Jan Grulich

Screen sharing in Plasma wayland session

One of the important missing features in Plasma wayland session is without a doubt possibility to share your screen or record you screen. To support this you need help of the compositor and somehow deliver all needed information to the client (application), in ideal way something what can be used by all DEs, such as Gnome. Luckily, this has been one of the primary goals of Pipewire, together with support for Flatpak. If you haven’t heard about Pipewire, it’s a new project that wants to improve audio and video handling in Linux, supporting all the usecases handled by PulseAudio and providing same level of handling for video input and output. With Pipewire supporting this, there was recently a new API added to xdg-desktop-portal for screen cast support and also for remote desktop. Using this API, applications can now have access to your screen content on Wayland sessions or in case they are running in sandbox. With various backend implementation, like xdg-desktop-portal-kde or xdg-desktop-portal-gtk, they just need to support one API to target all desktops. Screen cast portal works the way, that the client first needs to create a session between him and xdp (xdg-desktop-portal) backend implementation, user then gets a dialog with a screen he would like to share and starts screen sharing. Once he does that, xdp backend implementation creates a Pipewire stream, sends back response to the client with stream id and then client can connect to that stream and get its content. Once he no longer requests content of the selected stream, xdp backend implementation gets information that nobody is longer connected to the created Pipewire stream and can stop sharing screen information and xdp backend implementation is again ready to accept next requests for screen sharing. This is all happening in the background so there is really no cool picture I can show, at least this dialog which you get when you request to share a screen.

I finished support for screen cast portal in xdg-desktop-portal-kde last week and currently waiting for it to pass review and be merged to master. This is also currently blocked by two not merged reviews, one adding support for sending GBM buffers from KWin and one with new Remote Access Manager interface in KWayland, both authored by Oleg Chernovskiy, for which I’m really greatful. This all will hopefully land soon enough for Plasma 5.13. Testing this is currently a bit complicated as you need everything compiled yourself and besides my testing application there is really no app using this, except maybe Gnome remote desktop, but there should be support in future for this in Krfb, Chrome or in Firefox. Hopefully soon enough.

Last thing I would like to mention is for GSoC students. We also need remote desktop portal support to have full remote desktop experience so I decided to propose this as a GSoC idea so students can choose this interesting stuff as their GSoC work.

14 thoughts on “Screen sharing in Plasma wayland session

  1. Hope the best the KDE team and thier efforts
    Your making our life easier and improving opensource community.

  2. This should also let OBS work on wayland once they add support for it.

    Thanks!

  3. This sounds really cool.

    Would desktop sharing possibly also work from SDDM?

    I mean, in the way that if SDDM is running on a server, one could connect to it, log in, and get the desktop?

    And ideally, also disconnect from the session and reconnect later on?

  4. Next to screen sharing, e.g. applications like Skype also have the possibility to only share an application window. Is this also supported and in the scope of this project and pipewire?

    1. Pipewire doesn’t care about data you stream, you can easily define stream resolution and copy data to stream you need, also xdg-desktop-portal has API for this, there is option when establishing a session, whether you will be streaming window or screen. Problem is getting content of windows from KWin, we get only full screen at this moment, it would be easily possible to copy just content of a window to Pipewire stream if you know coordinations of that window and its size, which is not possible because of Wayland limitations.

  5. Will it be possible to share all screens? (e.g. dualscreen setup). Any plans to support sharing only specific windows/applications?

    Thanks for your work! 🙂

    1. Sharing of multiple screens should be possible, I just haven’t look into this yet. For sharing of windows/applications see my comment above.

  6. > support for sending GBM buffers from KWin

    Does it send a buffer of whole Desctop?
    Or does it send buffers of every layer?

  7. Looking at the screenshot I have to wonder how you would disambiguate screens if you happen to have two monitors of the same model and manufacturer and only want to share one of them (e.g. only the right, non-primary desktop). Maybe some reference to the the current screen configuration, but maybe you already thought of that and it’s just not visible in your example.

    1. Currently you will see same monitor twice, there is nothing implemented to distinguish between them. We will need to figure this out.

      1. Would it be possible to reuse (parts of) the screen configuration UI? It shows physical arrangement already.

        The opposite direction would also be nice, i.e. showing a “Shared” emblem in the Screen KCM.

Leave a Reply to jgrulich Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll To Top