Note: This was originally posted on Reddit. However, I have now decided to move the guide to lemmy and I will most likely delete the one on Reddit soon.
There are multiple options to achieve Wayland screen sharing with discord. I will cover two here.
OPTION 1 (Recommended):
There is a web-based discord client for Linux called "Webcord" that supports Wayland screen sharing. You just have to install it, open it, sign in, and you're done.
You can install it by downloading your preferred package from here or by using the flatpak version avaliable on flathub.
If you dont have flatpak set up - here is another quick guide.
That's it! You can now start screen sharing on Wayland!
In case you are interested in streaming your desktop audio as well, there is another Discord client called discord-screenaudio to do just that. It is also available on flathub.
OPTION 2:
What you'll need:
- Any Chromium-based browser (Firefox works too, but not as good)
- Web Apps (Should be available in your distribution Store, but here is a link to their GitHub: https://github.com/linuxmint/webapp-manager)
Step1:
Open WebApps and click on the little + icon in the bottom. Fill in the name (Discord) and the web Address (discord.com/app). The icon should apply automatically. As a browser, choose your Chromium-based browser. Then activate the switch "Isolated Profile" and click Ok.
Step2:
You now should be able to find Discord in your application-launcher of your choice. If you see discord twice, that means that you have now both the "real" Discord app and the new WebApp. Then try to launch the WebApp Discord. You now can sign in and use discord just as normal. However, there is still no Wayland support. We will activate it in step 3.
Step3: (unnecessary if you use Firefox)
While in the WebApp Discord, press Ctrl+T. A new window should appear. Then type chrome://flags in the address bar and press enter. Now search for "WebRTC PipeWire support" and change it from default to true. Now click "Relaunch" in the bottom of the window. If you have done everything right, you should now have Wayland support :)
I hope I could help you in some form, and have a nice day!
Optional: (And for more advanced users) Running the Discord WebApp without the use of Xwayland
Since Chrome version 97:
While in the Discord WebApp, press Ctrl+T. Type chrome://flags in the address bar and hit enter. Search for "Preferred Ozone platform". Change it from "Default" to "Auto". Then relaunch Discord. That's it.
Chrome Versions below 97:
Note: This is ONLY tested with arch/Manjaro and Brave. It could work on other systems and browsers too, but this is not guaranteed. So you basically just have to enable chromium Wayland flag. You can do this by creating a config file at $HOME/.config/brave-flags.conf. Do that by running nano $HOME/.config/brave-flags.conf
(If you are running another browser than Brave, I guess you could replace brave with the name of the other browser, but I didn't test this). Now insert the flag --enable-features=UseOzonePlatform --ozone-platform=wayland
save it by pressing Ctrl+O and exit with Ctrl+X. Now launch Discord again and see if it runs natively on Wayland. You can do this by installing and running xeyes (when installed, simply run xeyes in your terminal). When you move the mouse over a window and the eyes are moving, it uses Xwayland or X11. If not, you successfully activated Wayland.
Funny, I remember getting the exact same comment on Reddit when it was still there. While this is obviously correct, to me, it just feels wrong to use Discord in a browser. Also, other clients offer functionality that not even Discord in a browser supports. But for those who don't mind or don't need those extra features, it's a great solution, no doubt.