diff mbox series

[bug#70282,v2] gnu: gnome-shell: Wrap screencast service.

Message ID d5f358b4d17606032eba8a49ff7980720e7d4b4d.1712942808.git.dariqq@posteo.net
State New
Headers show
Series [bug#70282,v2] gnu: gnome-shell: Wrap screencast service. | expand

Commit Message

Dariqq April 12, 2024, 5:26 p.m. UTC
The screencast service can now find typelibs and gstreamer plugins.

* gnu/packages/linux.scm (gnome-shell)
[inputs]: Add gst-plugins-good and pipewire.
[#:phases]<'wrap-programs>: Create a wrapper for screencast service and use it.

Change-Id: I2c31bf1bd92e281b86c57b06988c6a3793a58d40
---

Hi,

Here is v2 of the patch. The wrapper is now created manually as I was unable to find a way to manipulate the gstreamer plugin load path from within javascript. Importantly this leaves the original javascript file untouched and therefore circumvents the argv[0] problem in v1.
All the required gstreamer plugins (pipewire and gst-plugins-good) are now inputs and are in the wrapper via GST_PLUGIN_SYSTEM_PATH.

I've also left a comment for the required home-pipewire-service.
In gnome-shell 45+ the invocation has changed to 'gjs -m service'. Should this also be a comment somewhere?


 gnu/packages/gnome.scm | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)


base-commit: 3dc26b4eaed448cbc02a80bafb2ebb6d908f2b4e

Comments

Liliana Marie Prikler April 19, 2024, 6:51 p.m. UTC | #1
Am Freitag, dem 12.04.2024 um 17:26 +0000 schrieb Dariqq:
> The screencast service can now find typelibs and gstreamer plugins.
> 
> * gnu/packages/linux.scm (gnome-shell)
> [inputs]: Add gst-plugins-good and pipewire.
> [#:phases]<'wrap-programs>: Create a wrapper for screencast service
> and use it.
> 
> Change-Id: I2c31bf1bd92e281b86c57b06988c6a3793a58d40
> ---
> 
> Hi,
> 
> Here is v2 of the patch. The wrapper is now created manually as I was
> unable to find a way to manipulate the gstreamer plugin load path
> from within javascript. Importantly this leaves the original
> javascript file untouched and therefore circumvents the argv[0]
> problem in v1.
> All the required gstreamer plugins (pipewire and gst-plugins-good)
> are now inputs and are in the wrapper via GST_PLUGIN_SYSTEM_PATH.
I'm not sure this fix is sounds.  It looks like it misses manual
invocation from the command line, does it not?  (Well, it's gnome-
shell, so if you have to invoke it from the command line, things are
broken, but still…)  What keeps you from wrapping the environment
variable in Javascript?

> I've also left a comment for the required home-pipewire-service.
> In gnome-shell 45+ the invocation has changed to 'gjs -m service'.
> Should this also be a comment somewhere?
Gnome-shell 45+ is currently irrelevant, but we might have to adapt
things once we get there on gnome-team.  We do need a better gjs-
patching strategy.

Cheers
diff mbox series

Patch

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 4934ade3dd..d68624344f 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -9381,6 +9381,7 @@  (define-public gnome-shell
             (add-after 'install 'wrap-programs
               (lambda* (#:key inputs #:allow-other-keys)
                 (let ((gi-typelib-path  (getenv "GI_TYPELIB_PATH"))
+                      (gst-plugin-path  (getenv "GST_PLUGIN_SYSTEM_PATH"))
                       (python-path
                        (string-join
                         (filter (lambda (item)
@@ -9405,7 +9406,39 @@  (define-public gnome-shell
                      (wrap-program (string-append #$output "/bin/" prog)
                        `("GUIX_PYTHONPATH"      ":" prefix (,python-path))
                        `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))))
-                   '("gnome-shell-perf-tool")))))
+                   '("gnome-shell-perf-tool"))
+                  ;; Make a wrapper for the screencast service
+                  ;; Requires a pipewire service running
+                  ;; (i.e. as provided by home-pipewire-service-type)
+                  (let* ((screencast "org.gnome.Shell.Screencast")
+                         (dir (string-append #$output "/share/gnome-shell/"))
+                         (dbus-service-dir (string-append #$output
+                                                          "/share/dbus-1/"
+                                                          "services/"))
+                         (wrapper (string-append dir screencast "-wrapper")))
+                    (call-with-output-file wrapper
+                      (lambda (port)
+                        (format port
+                                (string-append
+                                 "#!~a~%"
+                                 "export GI_TYPELIB_PATH=~a~%"
+                                 "export GST_PLUGIN_SYSTEM_PATH=~a~%"
+                                 "exec \"~a\" \"~a\" \"$@\"~%")
+                                (which "bash")
+                                (format #f "\"~a${~a:+:}$~a\""
+                                        gi-typelib-path
+                                        "GI_TYPELIB_PATH" "GI_TYPELIB_PATH")
+                                (format #f "\"~a${~a:+:}$~a\""
+                                        gst-plugin-path
+                                        "GST_PLUGIN_SYSTEM_PATH"
+                                        "GST_PLUGIN_SYSTEM_PATH")
+                                (string-append #$(this-package-input "gjs")
+                                               "/bin/gjs")
+                                (string-append dir screencast))))
+                    (chmod wrapper #o555)
+                    (substitute* (string-append dbus-service-dir screencast
+                                                ".service")
+                      (("Exec=.*") (string-append "Exec=" wrapper "\n")))))))
             (add-after 'install 'rewire
               (lambda* (#:key inputs #:allow-other-keys)
                 (for-each
@@ -9465,6 +9498,7 @@  (define-public gnome-shell
            gnome-settings-daemon
            graphene
            gst-plugins-base
+           gst-plugins-good
            ibus
            libcanberra
            libcroco
@@ -9475,6 +9509,7 @@  (define-public gnome-shell
            mesa-headers
            mutter
            network-manager-applet
+           pipewire
            polkit
            pulseaudio
            python-pygobject