Subject: [bug#70282] [PATCH v4] gnu: gnome-shell: Wrap screencast service.

From: Dariqq <[email-masked]>
Date: Wed, 8 May 2024 21:18:04 +0000

Hi Maxim,

On 08.05.24 21:51, Maxim Cournoyer wrote:
> Hi Dariqq,
> 
> Dariqq <[email-masked]> writes:
> 
>> Adjust screencast such that GI_TYPELIB_PATH and GST_PLUGIN_SYSTEM_PATH are set
>> before starting.
>>
>> Add all required gstreamer plugins to inputs.
>>
>> To be able to use it a running pipewire service is needed.
>>
>> * gnu/packages/gnome.scm (gnome-shell):
>> [inputs]: Add gst-plugins-good and pipewire.
>> [#:phases]<'wrap-programs>: Wrap org.gnome.Shell.Screencast.
> 
> Thanks for your efforts improving our GNOME desktop experience!
> 

The slight annoyance with this is that if pipewire is not running the 
option to enable the screen recorder is there but it will stop 
immediately. But at least searching online for this problem has some 
mentions of pipewire and i added a comment in the pacakge aswell. I 
think it is definitly a better solution than not knowing that the option 
is even there as the button does not get displayed at all if the service 
fails to start.

>> Change-Id: I2c31bf1bd92e281b86c57b06988c6a3793a58d40
>> ---
>> Here is v4 which appends the gstreamer plugins to
>> GST_PLUGIN_SYSTEM_PATH, handling the case when getenv returns null. I
>> think the difference between appendending or prepending in this case
>> is not too important as the user GST_PLUGIN_PATH should take
>> precedent. The more important thing is that the plugins are in any
>> plugin path at all.
>>
>>   gnu/packages/gnome.scm | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
>> index 92e35e3c5a..4bbff2a89b 100644
>> --- a/gnu/packages/gnome.scm
>> +++ b/gnu/packages/gnome.scm
>> @@ -9408,6 +9408,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)
>> @@ -9427,6 +9428,19 @@ (define-public gnome-shell
>>                                       "path => imports.gi.GIRepository.Repository."
>>                                       "prepend_search_path(path));\n"
>>                                       all)))
>> +                  ;; Screencast requires a pipewire service running
>> +                  ;; (i.e. as provided by home-pipewire-service-type)
>> +                  (substitute* (string-append #$output "/share/gnome-shell/"
>> +                                              "org.gnome.Shell.Screencast")
>> +                    (("imports\\.package\\.start" all)
>> +                     (string-append "'" gi-typelib-path "'.split(':').forEach("
>> +                                    "path => imports.gi.GIRepository.Repository."
>> +                                    "prepend_search_path(path));\n"
>> +                                    "imports.gi.GLib.setenv('GST_PLUGIN_SYSTEM_PATH',"
>> +                                    "[imports.gi.GLib.getenv('GST_PLUGIN_SYSTEM_PATH'),"
>> +                                    "'" gst-plugin-path "'].filter(v => v).join(':'),"
>> +                                    "true);\n"
>> +                                    all)))
> 
> Perhaps a simple patch would convey the change better and be easier to
> maintain in the future / be readily available for other distributions to
> use.

The simple patch that would do this is basically the patch from nixos in 
v1 of this which adds a shebang line for gjs to the service invocation 
files (rather than the dbus service invoking $gjs $service). The problem 
then is that wrap-program changes the filename to * .real which makes 
gjs unhappy.

The people from nix circumvent this by using some js at the beginning to 
reset the entrypoint to the correct value.

One nice way around avoiding the problem would be using wrap-script 
instead though that does not support gjs as interpreter (yet?) and 
adding that forces a rebuild of all packages due to (guix build utils) 
changing.

Maybe another comment, similiar to the one Liliana suggested earlier in 
this thread, could be added at the beginning to inform about changing to 
wrap script + patch instead once that is a viable option?

> 
>>                     (for-each
>>                      (lambda (prog)
>>                        (wrap-program (string-append #$output "/bin/" prog)
>> @@ -9492,6 +9506,7 @@ (define-public gnome-shell
>>              gnome-settings-daemon
>>              graphene
>>              gst-plugins-base
>> +           gst-plugins-good
>>              ibus
>>              libcanberra
>>              libcroco
>> @@ -9502,6 +9517,7 @@ (define-public gnome-shell
>>              mesa-headers
>>              mutter
>>              network-manager-applet
>> +           pipewire
>>              polkit
>>              pulseaudio
>>              python-pygobject
> 
> Otherwise, LGTM!
> 
Have a nice day