NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.91k stars 13.95k forks source link

zoom screen sharing on Gnome wayland #107233

Closed lambdafu closed 1 year ago

lambdafu commented 3 years ago

Zoom has a static OS detection based on /etc/os-release, and a hard-coded list of OS that support screen sharing under Gnome/Wayland. If I copy a Debian-based os-release into /etc, screen sharing works (it's slower than on x11, because it is based on taking screenshots every couple of seconds, but it is functional), while with the standard NixOS os-release it will crap out with an error message.

The solution can either be to give zoom a fake os-release file, or to coordinate with zoom upstream to add NixOS to the list of supported OSs.

More details (picture of error message and some work arounds for a similar issue on Debian unstable) here: https://www.guyrutenberg.com/2020/06/22/fixing-zoom-screen-sharing-on-debian-unstable/

3noch commented 3 years ago

I ran into this as well! Thanks for the workaround.

Another option is to try converting the desktop into a webcam as mentioned here: https://superuser.com/questions/411897/using-desktop-as-fake-webcam-on-linux

3noch commented 3 years ago

Instead of coordinating with Zoom, perhaps it would be possible to patch it on the Nixpkgs side?

tadfisher commented 3 years ago

There is a config setting to enable screen-sharing in Gnome, no os-release shenanigans required.

3noch commented 3 years ago

@tadfisher Do you know how to change that config?

3noch commented 3 years ago

@maralorn showed me that the following allows Zoom sharing on Gnome+Wayland to work:

    zoom = pkgs.zoom-us.overrideAttrs (old: {
      postFixup = old.postFixup + ''
        wrapProgram $out/bin/zoom-us --unset XDG_SESSION_TYPE
      '';});
davegallant commented 3 years ago

@maralorn showed me that the following allows Zoom sharing on Gnome+Wayland to work:

    zoom = pkgs.zoom-us.overrideAttrs (old: {
      postFixup = old.postFixup + ''
        wrapProgram $out/bin/zoom-us --unset XDG_SESSION_TYPE
      '';});

This gets around the error message but there doesn't appear to be a way to share the entire screen (only single applications).

3noch commented 3 years ago

@davegallant Good point. I forgot to mention that.

3noch commented 3 years ago

It's also worth noting that I can't seem to share Firefox (Wayland). I don't know why that would matter.

tadfisher commented 3 years ago

In ~/.config/zoomus.conf, make sure this line exists:

enableWaylandShare=true

Zoom uses mutter's screenshot protocol to do this, so it's not very efficient and can only share the entire desktop, not individual windows.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

nikolaiam commented 3 years ago

Still relevant, ran into this issue yesterday! Thanks everyone for the workarounds.

@maralorn showed me that the following allows Zoom sharing on Gnome+Wayland to work:

    zoom = pkgs.zoom-us.overrideAttrs (old: {
      postFixup = old.postFixup + ''
        wrapProgram $out/bin/zoom-us --unset XDG_SESSION_TYPE
      '';});

This doesn't seem to enable even the single-application-window sharing for me, just removes the error message. Any pointers on how to feed a fake os-release file for zoom?

maralorn commented 3 years ago

If the error message is gone I don't think modifying the os-release file can have any better effect.

Two tips:

  1. Single window sharing works only with xwayland windows. (you can find them by starting xeyes, when the eyes move the window under the cursor is an xwayland window.)

  2. Zoom has two apparently equivalent executables. I needed to add a second identical wrapper for the binary called "zoom" to consistently have it working.

nikolaiam commented 3 years ago

Thank you! Now I seem to able to share a window with

  nixpkgs.overlays = [
    (self: super:
    {
   zoomUsFixed = pkgs.zoom-us.overrideAttrs (old: {
      postFixup = old.postFixup + ''
        wrapProgram $out/bin/zoom-us --unset XDG_SESSION_TYPE
      '';});
   zoom = pkgs.zoom-us.overrideAttrs (old: {
      postFixup = old.postFixup + ''
        wrapProgram $out/bin/zoom --unset XDG_SESSION_TYPE
      '';});
      }
      )
  ];

and

  environment.systemPackages = with pkgs; [
    zoom
  ];

in my configuration.nix, but the option for sharing the desktop simultaneously disappeared. But at least I now have both options :) Thank you!

zoenglinghou commented 3 years ago

I stumble across this github issue... I do not really use Wayland (yet) or NixOS, but maybe bwrap is your solution? https://aur.archlinux.org/packages/wechat-uos/

knedlsepp commented 2 years ago

On plasma5 here using zoom with the --unset XDG_SESSION_TYPE and I can share only vscode/chromium/mattermost applications but not others (also not the entire screen). I'm guessing these coincidentally all work because they're built using the same web-browser backend magic. My guess that these might be using Xwayland and thus differ from all other apps was somewhat confirmed by being able to share LibreOffice Impress when it was started using GDK_BACKEND=x11 libreoffice. It seems that Qt based apps respond to XDG_SESSION_TYPE=x11. That's a good enough workaround for me until Zoom gets their pipewire solution ready.

In short:

Applications launched via:

alias zoom-sharing-workaround="XDG_SESSION_TYPE=x11 GDK_BACKEND=x11 "
zoom-sharing-workaround libreoffice

Can be shared on a Zoom that's got XDG_SESSION_TYPE unset before startup.

twhitehead commented 1 year ago

From the error message, the list of OSes checked for are

Doing a strings dump on opt/zoom/.zoom binary reveals

$ strings opt/zoom/.zoom
...
debian
fedora
centos
rhel
mageia
opensuse
antergos
manjaro
...

and looking at it in a hex editor shows these to be all adjacent null terminated strings.

Seems likely replacing one of these with nixos via the following overlay in ~/.config/nixpkgs/overlays/zoom-us.nix would likely be another way to get you passed the OS check

self: super: with self; {
  zoom-us = super.zoom-us.overrideAttrs (attrs: {
    nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [
      bbe
    ];               
    postFixup = ''
      cp $out/opt/zoom/zoom .
      bbe -e 's/\0manjaro\0/\0nixos\0\0\0/' < zoom > $out/opt/zoom/zoom
    '' + attrs.postFixup or "";
  } );
}

and indeed it does (although it still doesn't work for me as I am running sway instead of gnome).

Taneb commented 1 year ago

I don't know when this changed, but I can now share my screen with zoom on Gnome with Wayland, without doing anything funny to the executable. I think this issue can be closed.

godelized commented 1 year ago

I don't know when this changed, but I can now share my screen with zoom on Gnome with Wayland, without doing anything funny to the executable. I think this issue can be closed.

Same here. Running sway. Still installing zoom with the following expression but I'm not even sure it's still needed.

(zoom-us.overrideAttrs (old: {
      postFixup = old.postFixup + ''
        wrapProgram $out/bin/zoom --unset XDG_SESSION_TYPE
        wrapProgram $out/bin/zoom-us --unset XDG_SESSION_TYPE
      '';}))
twhitehead commented 1 year ago

@godelized I believe you are starting zoom in X11 mode by unsetting XDG_SESSION_TYPE=wayland.

It will let you share X11 windows that are being handled by Xwayland but not native wayland ones.

godelized commented 1 year ago

@godelized I believe you are starting zoom in X11 mode by unsetting XDG_SESSION_TYPE=wayland.

It will let you share X11 windows that are being handled by Xwayland but not native wayland ones.

You're most probably right. I think it was the only "fix" I found months ago on this repo issue board to be able to share windows. Did you test zoom under sway? Did you manage to share X11 windows and native ones? I didn't test again since I've set this configuration, I'll give it a try.

twhitehead commented 1 year ago

I couldn't get it to work under sway. There is a long delay and then it gives you a message about only supporting certain systems.

I switched from pulse to pipewire in hopes that that might help, but it didn't.

I did verify that it works under KDE running in wayland mode though. So at least it seems to be okay with NixOS.

I am wondering if it has something to do with the fact that my user systemd seems to have the kde xdg portal service running and not the wlr roots one that is mentioned in this blog

https://soyuka.me/make-screen-sharing-wayland-sway-work/

systemctl --user
  ...
  plasma-xdg-desktop-portal-kde.service
  wireplumber.service
  xdg-desktop-portal.service
  xdg-document-portal.service
  xdg-permission-store.service
  ...
twhitehead commented 1 year ago

Discovered a couple of issues with the sway one in NixOS 23.05 (looks like there were some commits that may have addressed this in master). First the systemd user environment is missing key info it needs

systemctl --user import-environment XDG_CURRENT_DESKTOP WAYLAND_DISPLAY

and the sway module in nixpkgs should be setting

xdg.portal.wlr.enable = true

and you need to enable it

xdg.portal.enable = true;

With all this, I get the option, and I can select a window or desktop to share. The share is all line noise though.