Fixing Slack black screen sharing on Wayland

For decades, Xorg has been the graphical server in the Linux world. But its own developers have been working for years in a replacement, Wayland.
Finally, Ubuntu 22.04 uses Wayland by default. But some programs are still not properly handling screen sharing on it, like Slack: when presenting, other users will see only a blank black screen.
Fortunatelly, there is a way to fix this, starting Slack with the --enable-features=WebRTCPipeWireCapturer param.
Make it permanent
Instead of always launch Slack using the terminal, let’s change the desktop shortcut.
But there is one additional problem: when Slack got updated, apt will overwrite our changes.
We’ll prevent that using dpkg-divert: using it, we can tell to apt to update another file and keep our changes.
So, open a terminal and run the below command to create the divert and rename the original file:
sudo dpkg-divert --add --rename --divert /usr/share/applications/slack.desktop.bak /usr/share/applications/slack.desktop 
Now let’s create a copy of the file to the original path and make our changes:
cd /usr/share/applications
sudo cp slack.desktop.bak slack.desktop
Using sudo, edit /usr/share/applications/slack.desktop file and change the Exec to be like this:
Exec=/usr/bin/slack --enable-features=WebRTCPipeWireCapturer %U
Save and exit.
Update the desktop database:
sudo update-desktop-database 
Done! Now the Slack screen sharing will work fine on Wayland and apt will not overwrite our changes!
Bonus
I’ve noticed that Slack produces a lot of useless entries in /var/log/syslog. If you want to avoid any info log level, add the -s param to the Exec line like this:
Exec=/usr/bin/slack --enable-features=WebRTCPipeWireCapturer -s %U
 
    
