Search code examples
x11xorg

Configure X11 for two graphics cards, three heads, two in Zaphodmode?


I have two graphics cards in my machine:

00:02.0 VGA compatible controller: Intel Corporation RocketLake-S GT1 [UHD Graphics 730] (rev 04)

02:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GT 1030] (rev a1)

Then I have three monitors. The Nvidia card has both DVI and HDMI outputs. The Intel has HDMI and Display Port.

I connected two Lenovo displays to the Nvidia, and an NEC to the Intel.

I do NOT want to use xinerama. Why? Because when it lets windows drag from screen to screen, which I do not want. I want each monitor to be its own display.

I am a long time Zaphod mode user, and I have come to love it.

So just what kind of config whizzeroodery do I need to do to get a dual seat, three headed configuration? I have two keyboards, and two mice?

Working xorg.conf please!

I tried using loginctl, and I tried using xdm, and evilwm. I had to login using termux from my cellphone to kill the xdm X sessions to get control of my computer back.


Solution

  • After many many trials and tribulations:

    First I needed to separate the xorg.conf into two files to simplify figuring things out. So I created:

    /etc/X11/xorg.conf-LENOVOS
     and
    /etc/X11/xorg.conf-NEC
    

    Then I changed my /etc/X11/xdm/Xservers file to:

    :0 local /usr/bin/X :0 vt8 -nolisten tcp -seat seat0 -keeptty -config /etc/X11/xorg.conf-LENOVOS
    :1 local /usr/bin/X :1 vt7 -nolisten tcp -seat seat1 -keeptty -config /etc/X11/xorg.conf-NEC
    

    Use "lspci | grep VGA" to query the PCI bus IDs for the video cards, see question for output. lspci showed me that:

    00:02.0  is Intel
    02:00.0  in Nvidia
    

    This translated to:

    BusID "PCI:2:0:0" for the Nvidia
    BusID "PCI:0:2:0" for the Intel
    

    which gets configured in the xorg.conf files.

    Now, you need to identify which keyboard and which mouse are on which port and attached to which seat. Use "loginctl" to do this.

    loginctl seat-status seat0
    

    will show you the current configuration. You should find both graphics cards and both mice and both keyboards all under seat0.

    Create and assign to seat1:

    I used:

    loginctl attach seat1 /sys/devices/pci0000:00/0000:00:02.0/drm/card0
    loginctl attach seat1 /sys/devices/pci0000:00/0000:00:14.0/usb1/1-12
    loginctl attach seat1 /sys/devices/pci0000:00/0000:00:14.0/usb1/1-5
    

    After finding the relevant strings identifying the keyboard and mouse. The busid for the first loginctl command matches the Intel card. Your numbers/devices WILL be different. You need to grope/grock the output of "loginctl seat-status seat0" to find them.

    Then.. here are my xorg.conf files:

    xorg.conf-LENOVOS:

    :~# cat /etc/X11/xorg.conf-LENOVOS 
    Section "Monitor"
            Identifier "LENOVO-LEFT"
    EndSection
    
    
    Section "Monitor"
            Identifier "LENOVO-RIGHT"
    #       Option "PreferredMode" "1600x1200"
    EndSection
    
    
    Section "Device"
            Identifier "NVIDIA-DVI-D-1"
            Driver "nouveau"
            Option "DRI" "3"
            Option "ModeDebug" "Yes"
    
    #   This next option, the first quoted string:
    #   "Monitor-HDMI-4" is the
    #   critical one.  The part following the '-' comes
    #   from the output of xrandr ran on the monitor
    #   which is connected to the card/port served
    #   by this Device section.  So on my two LENOVO
    #   screens I see:
    #  xrandr
    # Screen 0: minimum 320 x 200, current 1920 x 1200, maximum 16384 x 16384
    # DVI-D-1 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm
    # and
    # xrandr
    # Screen 1: minimum 320 x 200, current 1920 x 1200, maximum 16384 x 16384
    # HDMI-4 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm
            Option "Monitor-HDMI-4" "LENOVO-RIGHT"
    
            Option "ZaphodHeads" "HDMI-4"
            Option "DDC" "Off"
            BusID  "PCI:2:0:0"
            Screen 1
            MatchSeat "seat0"
    EndSection
    
    Section "Device"
            Identifier "NVIDIA-HDMI-4"
            Driver "nouveau"
            Option "DRI" "3"
            Option "ModeDebug" "Yes"
            Option "Monitor-DVI-D-1" "LENOVO-LEFT"
            Option "ZaphodHeads" "DVI-D-1"
            Option "DDC" "Off"
            BusID  "PCI:2:0:0"
            Screen 0
            MatchSeat "seat0"
    EndSection
    
    Section "Screen"
            Identifier "LENOVO2"
            Monitor "LENOVO-RIGHT"
            Device "NVIDIA-HDMI-4"
            MatchSeat "seat0"
    EndSection
    
    Section "Screen"
            Identifier "LENOVO1"
            Monitor "LENOVO-LEFT"
            Device "NVIDIA-DVI-D-1"
            MatchSeat "seat0"
    EndSection
    
    
    Section "ServerLayout"
            # The Identifier is not really important but must be unique.
            Identifier      "seat0"
    
            Screen 0 "LENOVO2"
            Screen 1 "LENOVO1" RightOf "LENOVO2"
            Option "Xinerama"       "off"
            Option "Clone"  "off"
    
            # MatchSeat means this layout will only be used when the "-seat seat-1"
            # parameter is given to /usr/bin/X, which most display managers will do
            # automatically.
            MatchSeat       "seat0"
    EndSection
    
    

    and

    xorg.conf-NEC:

    Section "Monitor"
            Identifier "HDMI-2"
    EndSection
    
    
    Section "Device"
            Identifier "HDMI_INTEL"
            Driver "intel"
            Option "DRI" "3"
            Option "ModeDebug" "Yes"
            Option "DDC" "Off"
            BusID  "PCI:0:2:0"
            # XXX screen 0 comment out maybe
            Screen 0 
            MatchSeat "seat1"
    EndSection
    
    Section "Screen"
            Identifier "NEC"
            Monitor "HDMI-2"
            Device "HDMI_INTEL"
            MatchSeat "seat1"
    EndSection
    
    
    Section "ServerLayout"
            # The Identifier is not really important but must be unique.
            Identifier "seat1"
    
            # This controls which Screen section is used in the layout, which in turn
            # dictates which GPU and monitor will be used.  The numbers can be omitted
            # if only one Screen is used (normally the case unless you are combining
            # monitors from different video cards).
            Screen          0       "NEC"
    
            # MatchSeat means this layout will only be used when the "-seat seat-1"
            # parameter is given to /usr/bin/X, which most display managers will do
            # automatically.
            MatchSeat       "seat1"
    EndSection
    

    All that complete, and issue the "/etc/init.d/xdm start" command. Then I had to login using both keyboards.

    Finally to access the NEC display ":1" from the Zaphodheads (":0.0 and :0.1"), use x2x:

    nohup x2x -to :1 -west -from :0 &
    

    Works beautifully with evilwm. So when I switch virtual desktops using CTRL-ALT-LEFTARROW or CTRL-ALT-RIGHTARROW, only the currently focused Zaphodhead switches. Kind of like having 16 virtual desktops, 8 per zaphod head. They switch independently. This is NOT possible with Xinerama.

    In case this helps anyone here is my seat1 status at the end of this process:

    ~$ loginctl seat-status seat1
    seat1
             Devices:
                      ├─/sys/devices/pci0000:00/0000:00:02.0/drm/card0
                      │ [MASTER] drm:card0
                      │ ├─/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1
                      │ │ [MASTER] drm:card0-DP-1
                      │ ├─/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-2
                      │ │ [MASTER] drm:card0-DP-2
                      │ ├─/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1
                      │ │ [MASTER] drm:card0-HDMI-A-1
                      │ ├─/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-2
                      │ │ [MASTER] drm:card0-HDMI-A-2
                      │ └─/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-3
                      │   [MASTER] drm:card0-HDMI-A-3
                      ├─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-12
                      │ usb:1-12
                      │ └─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/0003:03F0:0024.0004/input/input4
                      │   input:input4 "CHICONY HP Basic USB Keyboard"
                      │   ├─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/0003:03F0:0024.0004/input/input4/input4::capslock
                      │   │ leds:input4::capslock
                      │   ├─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/0003:03F0:0024.0004/input/input4/input4::numlock
                      │   │ leds:input4::numlock
                      │   └─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/0003:03F0:0024.0004/input/input4/input4::scrolllock
                      │     leds:input4::scrolllock
                      └─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5
                        usb:1-5
                        └─/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.0/0003:046D:C018.0009/input/input28
                          input:input28 "Logitech USB Optical Mouse"