Solved Screen sharing in KDE Plasma Wayland session

I am yet to get screen sharing to work in KDE plasma wayland session. Tried it with both firefox and chromium. It initially complains about missing pipewire and after running pipewire in konsole, the browser does offer the options to choose what to share (entire desktop, a selected window, a screen region, etc.) and a red dot appears in the taskbar indicating pipewire is recording (?) the screen. However, no screen is shared to the browser.

Am I missing some setting/configuration? I switched to plasma X11 session for now where screensharing works as expected, but I am keen to go back to wayland which feels more responsive than the X11 session. I am running FreeBSD 15.1-RELEASE-p4, with KDE plamsa 6.7.5. My firefox is version 157.0.1,2 and chromium is 151.0.7922.137_2.
 
you could try something like this

Code:
sudo pkg install plasma6-xdg-desktop-portal-kde

check where plasma6-xdg-desktop-portal-kde is installed
it should be in /usr/local/libexec/

start pipewire
the xdg-desktop-portal and plasma desktop portal

Code:
pipewire &
/usr/local/libexec/xdg-desktop-portal -r &
/usr/local/libexec/plasma6-xdg-desktop-portal-kde -r &

then start firefox or chromium and see if it works

here are my notes on setting up Pipewire with dwl and Wayland wlroots

 
Thanks NapoleonWils0n, for the recommendations.

I have xdg-desktop-portal and plasma desktop portal installed and running them as you advised unfortunately gives the same result - a red dot appears in task bar with a tool tip (screenshot below), however, the browser does not share the screen. The red dot gives an option to 'end' casting and when I click it, browser complains that it needs permission to share screen, so something seems to be happening while the red dot is present, despite no screen actually being shared.

1791725913651.png
1791725999473.png


I also noticed now that Firefox gives options to share its open tabs and this works fine even without pipewire running. Choosing to share the screen through 'Use operating system settings' (screenshot below) is what fails to work. So I am able to share other open tabs in firefox, but not other windows, entire screen, etc.

1791726972735.png
 
Looks like I may have solved my problem.

Previously, I did not have multimedia/wireplumber installed. After installing 'wireplumber', screen sharing works after manually starting 'pipewire' in konsole. I don't mind starting it manually, but is it desirable to auto-start it? If so, can anyone please suggest the correct way to do it?

Also, as screen sharing/recording is a fairly common use case and if 'pipewire + wireplumber' is a dependency for this in wayland, wouldn't it be nice to have both these packages installed as dependency in KDE plasma (I think pipewire is already installed as a dependency by 'plasma6-plasma') ?
 
sorry i should have mentioned you need wireplumber as well

i suppose its a trade off installing the packages as dependency for kde
missing functionality versus more dependencies

i suppose the other issue is making sure they are only installed for wayland and not x11

you could modify the firefox.desktop entry

1) create the following directory

Code:
mkdir -p ~/.local/share/applications

2) create the firefox.desktop file

Code:
vi ~/.local/share/applications/firefox.desktop

3) add the following code to the firefox.desktop entry file

Code:
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=sh -c 'pipewire &; /usr/local/libexec/xdg-desktop-portal -r &; /usr/local/libexec/plasma6-xdg-desktop-portal-kde -r &; firefox %U'
Terminal=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
Actions=NewWindow;NewPrivateWindow;

[Desktop Action NewWindow]
Name=Open a New Window
Exec=sh -c 'pipewire &; /usr/local/libexec/xdg-desktop-portal -r &; /usr/local/libexec/plasma6-xdg-desktop-portal-kde -r &; firefox -new-window'

[Desktop Action NewPrivateWindow]
Name=Open a New Private Window
Exec=sh -c 'pipewire &; /usr/local/libexec/xdg-desktop-portal -r &; /usr/local/libexec/plasma6-xdg-desktop-portal-kde -r &; firefox -private-window'

i have stripped out non english languages for brevity

if you need other languages you can copy the existing firefox.desktop entry
and then change the 3 exec lines from the code above

Code:
cp /usr/local/share/applications/firefox.desktop ~/.local/share/applications

see if that works

but the issues with is it would try and run those commands everytime you start firefox
which is not what you want as you would be running multiple versions of the commands

so you could manually kill them after stopping firefox

Code:
killall -9 xdg-desktop-portal plasma6-xdg-desktop-portal-kde pipewire 2>/dev/null

the best solution would to be have a wrapper script
that checks if those processes are running and if not start them and then start firefox

and change the exec line to point to that script

the other option would be to use a Makefile
so when you run make it starts the following

Code:
pipewire &
/usr/local/libexec/xdg-desktop-portal -r &
/usr/local/libexec/plasma6-xdg-desktop-portal-kde -r &

and then use make clean to stop them

Code:
killall -9 xdg-desktop-portal plasma6-xdg-desktop-portal-kde pipewire 2>/dev/null
 
Back
Top