If you've found that you can't share your screen on services like Teams or Discord in Ubuntu 22.04, you're not alone. Fortunately, the fix is straightforward.
The issue is related to the display server Wayland. In earlier versions of Ubuntu, Xorg was used, which didn’t have this problem. You can check which display server is being used with the following command:
echo $XDG_SESSION_TYPE
If the output is wayland, this is likely causing the issue. To enable screen sharing, we need to disable Wayland and enable Xorg (X11). Here's how to do it:
Edit the Custom Config File
Open the GDM configuration file in a text editor:
sudo nano /etc/gdm3/custom.conf
Disable Wayland
Inside the file, look for the following line:
#WaylandEnabled=false
To disable Wayland, remove the comment (the #) or replace the line with this:
WaylandEnabled=false
Save and Exit
After making the change, save the file and exit the editor.
Reboot the System
Reboot your system to apply the changes. To verify that the fix worked, run this command again:
echo $XDG_SESSION_TYPE
This should now return x11 instead of wayland. If it still shows wayland, restart the GDM service with the following command:
sudo systemctl restart gdm