canonical / lightdm

Display Manager
GNU General Public License v3.0
827 stars 138 forks source link

How to force seatN to display :N #275

Open shawarden opened 1 year ago

shawarden commented 1 year ago

I have a multiseat setup using 3 GPUs, loginctl and lightdm and it mostly just works. Two small areas where it doesn't is with bluetooth audio devices and ssh X forwarding misbehaving when I'm not on :0 or at least not the same display number as last time I logged in.

❯ ps axo pid,user,args | grep xorg
   6279 root     /usr/lib/Xorg :1 -seat seat0 -auth /run/lightdm/root/:1 -nolisten tcp vt7 -novtswitch
   6284 root     /usr/lib/Xorg :0 -seat seat2 -auth /run/lightdm/root/:0 -nolisten tcp
   6285 root     /usr/lib/Xorg :2 -seat seat1 -auth /run/lightdm/root/:2 -nolisten tcp

...instead of...

❯ ps axo pid,user,args | grep xorg
   6279 root     /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
   6284 root     /usr/lib/Xorg :1 -seat seat2 -auth /run/lightdm/root/:1 -nolisten tcp
   6285 root     /usr/lib/Xorg :2 -seat seat1 -auth /run/lightdm/root/:2 -nolisten tcp

Putting...

# Force seatN to run on display :N
[Seat:seat0]
xserver-command=/usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch #

[Seat:seat1]
xserver-command=/usr/lib/Xorg :1 -seat seat1 -auth /run/lightdm/root/:1 -nolisten tcp #

[Seat:seat2]
xserver-command=/usr/lib/Xorg :2 -seat seat2 -auth /run/lightdm/root/:2 -nolisten tcp #

...into /etc/lightdm.conf.d/71-seatdisplays.conf makes thing very confusing when I log in at what should be seat0. I end up on display :0 but either seat0, seat1 or seat2, despite the GPU and the mouse and keyboard USB ports feeding that monitor being bound to seat0:

❯ echo $DISPLAY
:0
❯ ps axo pid,user,args | grep xorg
   6711 root     /usr/lib/Xorg :1 -seat seat1 -auth /run/lightdm/root/:1 -nolisten tcp
   6713 root     /usr/lib/Xorg :2 -seat seat2 -auth /run/lightdm/root/:2 -nolisten tcp
   6731 root     /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
❯ loginctl list-sessions
SESSION  UID USER    SEAT  TTY
      3 1000 myuser  seat1
     c1  958 lightdm seat2
     c2  958 lightdm seat0

3 sessions listed.

If I remove the comment # from the end of the xserver-command line, I end up on my correct seat0 but not necessarily display :0. It auto appends what's actually happening to the manually set command and while I end up on the correct seat number, the display is again random:

❯ echo $DISPLAY
:2
❯ ps axo pid,user,args | grep xorg
   6423 root     /usr/lib/Xorg :1 -seat seat1 -auth /run/lightdm/root/:1 -nolisten tcp :0 -seat seat1 -auth /run/lightdm/root/:0 -nolisten tcp
   6428 root     /usr/lib/Xorg :2 -seat seat2 -auth /run/lightdm/root/:2 -nolisten tcp :1 -seat seat2 -auth /run/lightdm/root/:1 -nolisten tcp
   6437 root     /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch :2 -seat seat0 -auth /run/lightdm/root/:2 -nolisten tcp vt7 -novtswitch
❯ loginctl list-sessions
SESSION  UID USER    SEAT  TTY
      3 1000 myuser  seat0
     c1  958 lightdm seat1
     c2  958 lightdm seat2

3 sessions listed.

Since it looks like it's just appending the command with whatever it wants, I've tried setting xserver-command to something inane like sleep 1; /usr/lib/Xorg for seat1 and 2 but that just breaks seat1 and 2:

❯ echo $DISPLAY
:0
❯ ps axo pid,user,args | grep xorg
   6064 root     /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
❯ loginctl list-sessions
SESSION  UID USER   SEAT  TTY
      3 1000 myuser seat0

1 sessions listed.

I can only assume it's just whatever command executes or completes first gets :0 and so on.

Is there a way to force seat0 to display :0, seat1 to :1 and seat2 to :2?

Alternatively, is there a way to delay the launch of seat1 and 2 so seat0 always gets first crack at :0?