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

From: Ludovic Courtès <[email-masked]>
Date: Thu, 14 Sep 2023 22:38:46 +0200

Hello Brian & Oleg,

Brian Cully <[email-masked]> skribis:

> If, for instance, I start an X session on the console, allocating the
> first display (:0), everything will start up correctly. If I then log in
> from a remote host with SSH using X forwarding, I'll get another display
> allocated (:1), but this isn't accounted for. If I do these operations
> in reverse, first starting my X-forwarded SSH session, then logging in
> via console, it will almost certainly not do what just about anyone
> wants.

Yeah, and similarly with the scenario Oleg describes.

> This does presume the Shepherd can be started multiple times for a given
> user,

No no, but it assumes simple scenarios: when you first login locally, X
is not running yet, but you eventually start it and that’s the display
you want your services to use.  Anything beyond that won’t work, as you
point out.

A simple improvement would be to stop the service when the relevant
/tmp/.X11-unix socket disappears.

As for which display to use when several are available (the SSH example
above), I don’t know.  Apparently elogind doesn’t know which display
corresponds to a “seat”.  Maybe we shouldn’t try to guess and instead
let users specify it, for instance with ‘herd start x11-display :42’?

Now, without this service the situation is even worse: shepherd and its
sub-processes inherit whatever ‘DISPLAY’ value was in its environment,
if any, and that’s it.  This service is a hack, but might still do more
good than harm?

Ludo’.