Subject: [bug#65343] [PATCH v2] home: services: Add 'x11-display' service.

From: Oleg Pykhalov <[email-masked]>
Date: Fri, 03 Nov 2023 19:58:29 +0300

Hi Ludovic,

apologize for the slow response. I had some minor issues with setting a
'home shepherd' instance in a fresh testing virtual machine (not related
to the current issue).

Ludovic Courtès <[email-masked]> writes:

> * gnu/home/services/desktop.scm (x11-shepherd-service): New procedure.
> (home-x11-service-type): New variable.
> (redshift-shepherd-service): Add 'requirement' field.
> (home-redshift-service-type): Extend 'home-x11-service-type'.
> * doc/guix.texi (Desktop Home Services): Document it.
> ---
>  doc/guix.texi                 | 34 ++++++++++++++
>  gnu/home/services/desktop.scm | 87 +++++++++++++++++++++++++++++++++--
>  2 files changed, 116 insertions(+), 5 deletions(-)
>
> Changes in this version:
>
>   1. ‘x11-display’ defaults to the ‘DISPLAY’ value of the ‘shepherd’
>      process, if any.  This makes it fully compatible with what we
>      have now (processes basically inherit environment variables of
>      the ‘shepherd’ process).
>
>   2. One can specify a display: ‘herd start x11-display :42’.
>
> WDYT?

I think we are going in the right direction, thank you for the
implementation!

During testing in a virtual machine I found an issue, which could be
reproduced with the steps bellow. It's not an emergency issue which
blocks the patch from merging, because we still have a workaround in our
pocket (stop and start ‘shepherd’ manually on a specific ‘DISPLAY’).

- start ‘shepherd’ manually on ‘127.0.0.1:5’ by typing ‘shepherd’ in a
  GUI terminal;
- stop ‘x11-display’ with ‘herd stop x11-display’;
- start ‘x11-display’ with ‘herd start x11-display :1’;
- start ‘redshift’ with ‘herd start redshift’.

The ‘redshift’ service starts a ‘redshift’ process.  The
/proc/REDSHIFT_PID/environ file has a ‘DISPLAY’ variable setted to
‘127.0.0.1:5’.

I expect that in /proc/REDSHIFT_PID/environ file the value of ‘DISPLAY’
environment variable should be ‘:1’, as in ‘x11-display’ service started
right before the ‘redshift’ service.

Following services could be used to get ‘:1’ and ‘127.0.0.1:5’:
--8<---------------cut here---------------start------------->8---
    (service lxqt-desktop-service-type)

    (service xvnc-service-type (xvnc-configuration
                                 (display-number 5)
                                 (localhost? #f)
                                 (xdmcp? #t)
                                 (inetd? #t)))

    (modify-services %desktop-services
                     (gdm-service-type config => (gdm-configuration
                                                  (inherit config)
                                                  (auto-suspend? #f)
                                                  (xdmcp? #t))))
--8<---------------cut here---------------end--------------->8---

A workaround for this issue to stop ‘shepherd’ with ‘herd stop root’,
and start it on ‘:1’ with ‘shepherd’ in a GUI terminal.

Regards,
Oleg.