[PATCH 0/7] Improve screen sharing support under Wayland

  • Done
  • quality assurance status badge
Details
2 participants
  • Josselin Poiret
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Josselin Poiret
Severity
normal
J
J
Josselin Poiret wrote on 14 Dec 2021 22:45
(address . guix-patches@gnu.org)(name . Josselin Poiret)(address . dev@jpoiret.xyz)
20211214214502.24913-1-dev@jpoiret.xyz
Hello,

This patchset updates and improves various packages related to screen
sharing/screeshotting on Wayland, and especially wlroots-based
compositors.

I can get screensharing working in icecat on sway by manually starting
pipewire then wireplumber (and then xdg-desktop-portal-wlr followed by
xdg-desktop-portal if they're not installed in your profile, otherwise
your user DBus session will launch them automatically), and starting
icecat with

`LD_LIBRARY_PATH="$(./pre-inst-env guix build
pipewire)/lib:$LD_LIBRARY_PATH" icecat`

since the pipewire library is dlopened by libwebrtc rather than
statically or dynamically linked. We could possibly add this to the
icecat package, as it has a wrapper doing a similar thing for other
libraries.

Another way to test screensharing without icecat would be to use this
python script [1], using `guix shell python python-pygobject
gst-plugins-bad pipewire python-dbus -- python3 xdp-screen-cast.py`.

I also took the liberty to patch xdg-desktop-portal-wlr's
screenshotting process, as it simply execl'd to slurp and grim. Along
with an update to flameshot, I can use the latter properly on sway as
well.

Best,
Josselin


Josselin Poiret (7):
gnu: pipewire-0.3: Use new input style
gnu: pipewire-0.3: Update to 0.3.41
gnu: Add wireplumber
gnu: xdg-desktop-portal-wlr: Update to 0.5.0
gnu: xdg-desktop-portal-wlr: Use new input style
gnu: xdg-desktop-portal-wlr: Add binary dependencies
gnu: flameshot: Update to 0.10.2

gnu/local.mk | 1 +
gnu/packages/freedesktop.scm | 38 ++++++++++----
gnu/packages/image.scm | 4 +-
gnu/packages/linux.scm | 52 +++++++++++++++----
...g-desktop-portal-wlr-harcoded-length.patch | 28 ++++++++++
5 files changed, 100 insertions(+), 23 deletions(-)
create mode 100644 gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch

--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 1/7] gnu: pipewire-0.3: Use new input style
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-1-dev@jpoiret.xyz
* gnu/packages/linux.scm (pipewire-0.3): Refactor it.
---
gnu/packages/linux.scm | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

Toggle diff (30 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index c752df7996..191ab757e4 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -8134,15 +8134,14 @@ (define-public pipewire-0.3
(modify-phases %standard-phases
;; Skip shrink-runpath, otherwise validate-runpath fails.
(delete 'shrink-runpath))))
- (inputs
- (append (package-inputs pipewire)
- `(("avahi" ,avahi)
- ("bluez" ,bluez)
- ("jack" ,jack-2)
- ("ldacbt" ,ldacbt)
- ("pulseaudio" ,pulseaudio)
- ("vulkan-loader" ,vulkan-loader)
- ("vulkan-headers" ,vulkan-headers))))))
+ (inputs (modify-inputs (package-inputs pipewire)
+ (prepend avahi
+ bluez
+ jack-2
+ ldacbt
+ pulseaudio
+ vulkan-loader
+ vulkan-headers)))))
(define-public ell
(package
--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 2/7] gnu: pipewire-0.3: Update to 0.3.41
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-2-dev@jpoiret.xyz
* gnu/packages/linux.scm (pipewire-0.3): Update it.
---
gnu/packages/linux.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (24 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 191ab757e4..77632c51c9 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -8114,7 +8114,7 @@ (define-public pipewire-0.3
(package
(inherit pipewire)
(name "pipewire")
- (version "0.3.40")
+ (version "0.3.41")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -8123,7 +8123,7 @@ (define-public pipewire-0.3
(file-name (git-file-name name version))
(sha256
(base32
- "1c6gni23l5w3ghwqnfs712kjj6l1825f0ib8a6r2xc1ymr0sx3kr"))))
+ "05ksl2nbn00gvdmnmffa8q8r3z29ip75554d36xchsrhqq4sxdcm"))))
(arguments
'(#:configure-flags
(list (string-append "-Dudevrulesdir=" (assoc-ref %outputs "out")
--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 3/7] gnu: Add wireplumber
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-3-dev@jpoiret.xyz
* gnu/packages/linux.scm (wireplumber): Add it.
---
gnu/packages/linux.scm | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

Toggle diff (51 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 77632c51c9..ec41a5450b 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -88,6 +88,7 @@ (define-module (gnu packages linux)
#:use-module (gnu packages bash)
#:use-module (gnu packages bison)
#:use-module (gnu packages boost)
+ #:use-module (gnu packages build-tools)
#:use-module (gnu packages calendar)
#:use-module (gnu packages check)
#:use-module (gnu packages cpio)
@@ -8143,6 +8144,36 @@ (define-public pipewire-0.3
vulkan-loader
vulkan-headers)))))
+(define-public wireplumber
+ (package
+ (name "wireplumber")
+ (version "0.4.5")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url
+ "https://gitlab.freedesktop.org/pipewire/wireplumber.git")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1k56i5cardwr03vkldg68714hyksyp1vb0b315yw1bilaj2ka30i"))))
+ (build-system meson-build-system)
+ (arguments
+ `(#:configure-flags '("-Dsystemd=disabled"
+ "-Dsystem-lua=true")))
+ (native-inputs
+ `(("glib-bin" ,glib "bin")
+ ("pkg-config" ,pkg-config)))
+ (inputs (list dbus elogind glib lua pipewire-0.3))
+ (home-page "https://gitlab.freedesktop.org/pipewire/wireplumber")
+ (synopsis "Session / policy manager implementation for PipeWire")
+ (description "WirePlumber is a modular session / policy manager for
+PipeWire and a GObject-based high-level library that wraps PipeWire's API,
+providing convenience for writing the daemon's modules as well as external
+tools for managing PipeWire.")
+ (license license:expat)))
+
(define-public ell
(package
(name "ell")
--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 4/7] gnu: xdg-desktop-portal-wlr: Update to 0.5.0
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-4-dev@jpoiret.xyz
* gnu/packages/freedesktop.scm (xdg-desktop-portal-wlr): Update it.
---
gnu/packages/freedesktop.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (24 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index a14fba862c..a1608cbb70 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -2378,7 +2378,7 @@ (define-public xdg-desktop-portal-gtk
(define-public xdg-desktop-portal-wlr
(package
(name "xdg-desktop-portal-wlr")
- (version "0.4.0")
+ (version "0.5.0")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -2387,7 +2387,7 @@ (define-public xdg-desktop-portal-wlr
(file-name (git-file-name name version))
(sha256
(base32
- "13fbzh8bjnhk4xs8j9bpc01q3hy27zpbf0gkk1fnh3hm5pnyfyiv"))))
+ "1ipg35gv8ja39ijwbyi96qlyq2y1fjdggl40s38rv68bsya8zry1"))))
(build-system meson-build-system)
(arguments
`(#:configure-flags
--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 5/7] gnu: xdg-desktop-portal-wlr: Use new input style
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-5-dev@jpoiret.xyz
* gnu/packages/freedesktop.scm (xdg-desktop-portal-wlr): Refactor it.
---
gnu/packages/freedesktop.scm | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

Toggle diff (26 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index a1608cbb70..e1827ffdad 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -2395,13 +2395,12 @@ (define-public xdg-desktop-portal-wlr
"-Dsd-bus-provider=libelogind")))
(native-inputs
(list cmake pkg-config))
- (inputs
- `(("elogind" ,elogind)
- ("iniparser" ,iniparser)
- ("pipewire" ,pipewire-0.3)
- ("inih" ,libinih)
- ("wayland" ,wayland)
- ("wayland-protocols" ,wayland-protocols)))
+ (inputs (list elogind
+ iniparser
+ libinih
+ pipewire-0.3
+ wayland
+ wayland-protocols))
(home-page "https://github.com/emersion/xdg-desktop-portal-wlr")
(synopsis "@code{xdg-desktop-portal} backend for wlroots")
(description
--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 6/7] gnu: xdg-desktop-portal-wlr: Add binary dependencies
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-6-dev@jpoiret.xyz
* gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch:
Add it.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/freedesktop.scm (xdg-desktop-portal-wlr): Add
dependencies on bash-minimal, grim and slurp, and hardcode the paths
in source.
---
gnu/local.mk | 1 +
gnu/packages/freedesktop.scm | 23 +++++++++++++--
...g-desktop-portal-wlr-harcoded-length.patch | 28 +++++++++++++++++++
3 files changed, 50 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch

Toggle diff (92 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index a138e574d0..9bbcd42733 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1914,6 +1914,7 @@ dist_patch_DATA = \
%D%/packages/patches/wpa-supplicant-CVE-2021-27803.patch \
%D%/packages/patches/wpa-supplicant-CVE-2021-30004.patch \
%D%/packages/patches/x265-arm-flags.patch \
+ %D%/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch\
%D%/packages/patches/xf86-video-ark-remove-mibstore.patch \
%D%/packages/patches/xf86-video-mach64-bool-to-boolean.patch \
%D%/packages/patches/xf86-video-mach64-glibc-2.20.patch \
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index e1827ffdad..1ed09dbf2c 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -2387,18 +2387,37 @@ (define-public xdg-desktop-portal-wlr
(file-name (git-file-name name version))
(sha256
(base32
- "1ipg35gv8ja39ijwbyi96qlyq2y1fjdggl40s38rv68bsya8zry1"))))
+ "1ipg35gv8ja39ijwbyi96qlyq2y1fjdggl40s38rv68bsya8zry1"))
+ (patches (search-patches "xdg-desktop-portal-wlr-harcoded-length.patch"))))
(build-system meson-build-system)
(arguments
`(#:configure-flags
'("-Dsystemd=disabled"
- "-Dsd-bus-provider=libelogind")))
+ "-Dsd-bus-provider=libelogind")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'hardcode-binaries
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((sh (search-input-file inputs "/bin/sh"))
+ (grim (search-input-file inputs "/bin/grim"))
+ (slurp (search-input-file inputs "/bin/slurp")))
+ (substitute* "src/screenshot/screenshot.c"
+ (("grim") grim)
+ (("slurp") slurp)
+ (("execl\\(\"/bin/sh\", \"/bin/sh\"")
+ (string-append "execl(\"" sh "\", \"" sh "\"")))
+ (substitute* "src/screencast/screencast.c"
+ (("execvp\\(\"sh")
+ (string-append "execvp(\"" sh)))))))))
(native-inputs
(list cmake pkg-config))
(inputs (list elogind
+ bash-minimal
+ grim
iniparser
libinih
pipewire-0.3
+ slurp
wayland
wayland-protocols))
(home-page "https://github.com/emersion/xdg-desktop-portal-wlr")
diff --git a/gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch b/gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch
new file mode 100644
index 0000000000..b499a039e8
--- /dev/null
+++ b/gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch
@@ -0,0 +1,28 @@
+From 3121eeb5e68bedd6e2398f35b9bd60b69709a47e Mon Sep 17 00:00:00 2001
+From: Josselin Poiret <dev@jpoiret.xyz>
+Date: Tue, 14 Dec 2021 18:49:54 +0100
+Subject: [PATCH] Replace hardcoded command length
+
+---
+ src/screenshot/screenshot.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/screenshot/screenshot.c b/src/screenshot/screenshot.c
+index 9df0ea7..5f27681 100644
+--- a/src/screenshot/screenshot.c
++++ b/src/screenshot/screenshot.c
+@@ -42,8 +42,9 @@ static bool exec_screenshooter_interactive(const char *path) {
+ perror("fork");
+ return false;
+ } else if (pid == 0) {
+- char cmd[strlen(path) + 25];
+- snprintf(cmd, sizeof(cmd), "grim -g \"$(slurp)\" -- %s", path);
++ const char cmd_fmt[] = "grim -g \"$(slurp)\" -- %s";
++ char cmd[strlen(path) + sizeof(cmd_fmt)];
++ snprintf(cmd, sizeof(cmd), cmd_fmt, path);
+ execl("/bin/sh", "/bin/sh", "-c", cmd, NULL);
+ perror("execl");
+ exit(127);
+--
+2.34.0
+
--
2.34.0
J
J
Josselin Poiret wrote on 14 Dec 2021 22:47
[PATCH 7/7] gnu: flameshot: Update to 0.10.2
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
20211214214752.25096-7-dev@jpoiret.xyz
* gnu/packages/image.scm (flameshot): Update it.
---
gnu/packages/image.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (24 lines)
diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index b6378a3890..8bed2da65c 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -1823,7 +1823,7 @@ (define-public libiptcdata
(define-public flameshot
(package
(name "flameshot")
- (version "0.8.5")
+ (version "0.10.2")
(source
(origin
(method git-fetch)
@@ -1833,7 +1833,7 @@ (define-public flameshot
(file-name (git-file-name name version))
(sha256
(base32
- "1z77igs60lz106vsf6wsayxjafxm3llf2lm4dpvsqyyrxybfq191"))))
+ "07n98pp5i6i51g7a4vqwbd6xarihzl7r714r2knvw2zn5mlj55dd"))))
(build-system qt-build-system)
(native-inputs
(list qttools))
--
2.34.0
M
M
Mathieu Othacehe wrote on 19 Dec 2021 13:22
Re: bug#52492: [PATCH 0/7] Improve screen sharing support under Wayland
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492-done@debbugs.gnu.org)
87mtkwokch.fsf@gnu.org
Hey Josselin,

Thanks for working on that. I fixed a few minor details and pushed the
series.

Toggle quote (6 lines)
> I can get screensharing working in icecat on sway by manually starting
> pipewire then wireplumber (and then xdg-desktop-portal-wlr followed by
> xdg-desktop-portal if they're not installed in your profile, otherwise
> your user DBus session will launch them automatically), and starting
> icecat with

As discussed on #guix, we may need to find a way to start those services
automatically.

Toggle quote (5 lines)
> since the pipewire library is dlopened by libwebrtc rather than
> statically or dynamically linked. We could possibly add this to the
> icecat package, as it has a wrapper doing a similar thing for other
> libraries.

Seems fair.

I also tried to run obs, this way:

Toggle snippet (3 lines)
QT_QPA_PLATFORM=wayland obs

was prompted for a screen/window to capture using pipewire, but then I
have the following error, does that ring a bell?

Toggle snippet (29 lines)
info: ------------------------------------------------
info: Loaded scenes:
info: - scene 'Scene':
info: - source: 'Window Capture (PipeWire)' (pipewire-window-capture-source)
info: ------------------------------------------------
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
info: [pipewire] available cursor modes:
info: [pipewire] - Metadata
info: [pipewire] - Always visible
info: [pipewire] - Hidden
Attempted path: share/obs/obs-studio/images/overflow.png
Attempted path: /gnu/store/1fp8wl9y2i72ld59d1spw85xvw9l88ws-obs-27.0.1/share/obs/obs-studio/images/overflow.png
info: [pipewire] screencast session created
info: [pipewire] asking for window…
info: adding 42 milliseconds of audio buffering, total audio buffering is now 42 milliseconds (source: Mic/Aux)

warning: [pipewire] Failed to start screencast, denied or cancelled by user
info: PipeWire initialized (sender name: 1_1734)
info: User added source 'Screen Capture (PipeWire)' (pipewire-desktop-capture-source) to scene 'Scene'
info: [pipewire] available cursor modes:
info: [pipewire] - Metadata
info: [pipewire] - Always visible
info: [pipewire] - Hidden
info: [pipewire] screencast session created
info: [pipewire] asking for desktop…
warning: [pipewire] Failed to start screencast, denied or cancelled by user
^Cinfo: ==== Shutting down ==================================================

Thanks,

Mathieu
Closed
M
M
Mathieu Othacehe wrote on 19 Dec 2021 13:23
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
87ilvkokak.fsf_-_@gnu.org
You are missing the final dot on the commit title of each commit.

Mathieu
M
M
Mathieu Othacehe wrote on 19 Dec 2021 13:24
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
87ee68ok9o.fsf_-_@gnu.org
Toggle quote (4 lines)
> + (native-inputs
> + `(("glib-bin" ,glib "bin")
> + ("pkg-config" ,pkg-config)))

I replaced it to use the new style.

Mathieu
M
M
Mathieu Othacehe wrote on 19 Dec 2021 13:24
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 52492@debbugs.gnu.org)
87a6gwok8z.fsf_-_@gnu.org
Toggle quote (2 lines)
> + (lambda* (#:key inputs outputs #:allow-other-keys)

outputs is not required here.

Mathieu
?