Solved Strange Xorg behaviour with two monitors

I have two monitors, one is 1920x1080 and the other is 3840x2160 (4K). Below is a picture of their arrangement
1751934757534.png

The left monitor is 1920x1080 and the right one is 3840x2160. The left monitor is connected using HDMI, the right is connected using DP. I, of course, want the HDMI monitor to be left of the DP monitor. The automatic Xorg configuration failed at doing this, so I tried to configure this using 10-monitor.conf:
Code:
Section "Monitor"
    Identifier "HDMI-0"
    Option "LeftOf" "DP-0"
EndSection

Section "Monitor"
    Identifier "DP-0"
    Option "primary" "true"
EndSection
This did nothing, the HDMI monitor was still treated as if it were right of the DP.
Video example | Catbox host (forum doesn't allow video attachments)

What is strange, though, is that making the HDMI monitor the primary one does result in the desired outcome
Code:
Section "Monitor"
    Identifier "HDMI-0"
    Option "primary" "true"
EndSection

Section "Monitor"
    Identifier "DP-0"
EndSection
Video example | Catbox host

Now, why don't I just leave it like that since it "just werks"? Two reasons:
1. The HDMI monitor is NOT my primary monitor
2. The DWM UI becomes smaller when the HDMI monitor is set to primary, for whatever reason.

I also tested other options in the 10-monitor.conf, the HDMI monitor responds perfectly to the "rotate" option, therefore it can't be that it's unresponsive to the file (though the primary option change should have already made this clear).
 
Try using
Code:
xrandr --output DP-0 --mode 3840x2160 --rotate normal --output HDMI-0 --mode 1920x1080 --rotate normal --left-of DP-0
in your ~/.xinitrc
for details and more options see xrandr(1)
 
  • Like
Reactions: mer
Try using
Code:
xrandr --output DP-0 --mode 3840x2160 --rotate normal --output HDMI-0 --mode 1920x1080 --rotate normal --left-of DP-0
in your ~/.xinitrc
for details and more options see xrandr(1)
I'm aware of xrandr, what I want to know is why Xorg .conf files don't work properly.
 
This did nothing, the HDMI monitor was still treated as if it were right of the DP.
Keep in mind that the Identifier is just a free form name, you can call it anything you want. You can call them "monitor1" and "monitor2", the identifier doesn't determine which monitor it applies the configuration to.
 
Rich (BB code):
Section "Monitor"
    Identifier "DP-0"
    Option "primary" "true"
EndSection
"primary" should be "Primary" with a capital "P" (assuming it's not a transcript error or something).

xorg.conf(5)
Rich (BB code):
       Option "Primary" "bool"
              This optional entry specifies that the monitor should be treated
              as the primary monitor. (RandR 1.2-supporting drivers only)
 
Does "P|primary" mean "left of" or does it mean "Start here"? I think xrandr has a "--primary" implying "sorted first in Xinerama and RANDR geometry requests" so not the same as "left of"

As T-Daemon points out, "Case" may matter. I don't if case actually matters in xorg.conf files but suspect "Yes it does".
 
it mean "Start here"
There are two kinds of "primary monitor" - the one the graphic card picks, and the one you may define in X.

I played a lot with my multihead setups, several graphic cards, and grown grey hair which port of the graphics adapter comes to which monitor, and if the fuck there is some comprehandable system. Those belong to the things you cannot find any documentation on by any graphic cards supplier at all beyond all this multimedia website "...only the finest hop hand-picked by the prettiest girls are used for our best swill..." BS.
All I can say is: It's mostly trial and error.
The cards seem to chose the order of the monitors first giving priority to certain type of port (DP before HDMI, but this also may differ from card to card), then which one replies fastest. So your primary monitor chosen by the card - the one your boot screen appears - will be the fastest responding one at the DPs (something like that.)

For X you can tell another one shall be primary. But this has no effect on which monitor is placed where. Only where graphics output appears that is configured/told to appear on primary (such e.g. games; but also that doesn't always work correctly, which may depend on the game. the window manager may also play a role)

The order can be chosen freely with "left-of" and "right-of" (while there also is "above", "below" and "same":cool: - you can do nice set-ups!) and does not neccassarily need a primary defined, as long as there is no contradiction - and you know which monitor comes where.
Once one single cable is pulled, all bets are off, again, and you have to restart X.😂
I use colorcoded markings at my four monitor's cables to know which one belongs into which plug, because if you once played the "where is the pea now?" until you finally get your multihead set up, you won't do it again. 🤓

my current setup:
1751991839719.png
 
Last edited:
I was going to "quote" but :) Me rereading the xrandr man page there is a big difference between position (left/right/above/below) is distinct from primary/not primary and they are not mutually exclusive. Basically you could define "display A is left of display B but B is primary". It seems like the xorg.conf follows similar pattern but maybe one needs to pay attention to case of key words. I wonder if Primary indicates "where windows should open" and stuff like that.

Toss in the fact that man xorg.conf references xrandr, I think the OP solution is come up with the xrandr command that gives desired results and then translate into xorg.conf snippets.
 
I wonder if Primary indicates "where windows should open" and stuff like that.
That's exactly what it means. But not for every App/WM/DE it works always perfectly reliably (search me.)

My xrandr line looks more like this (if you do it in ~/.xinitrc 🥸 [my setup works 😁]):
Code:
... --output DP-2 --mode 1920x1200 --rotate left --pos 3120x0 ...
As you can see I don't use "left-of" but absolute positions in pixels.
Point is I have two kind of monitors, two are turned 90°, and pixels on monitors are rectangular but not squares, so you have to adjust a bit the height of the monitors and their place in the screen to not become too annoyed the mouse hangs everytime you change the monitor - it's also a question of getting accustomized to it 😎
 
  • Like
Reactions: mer
The xrandr does achieve the desired effect, yes.
Issue solved using xrandr.

As I wrote above, I had the same issues like you. (I also started with a second monitor.) I spared the part with messing around with not really working .conf files in /usr/local/share/X11/xorg.conf.d/. Since we're not debugging here, who cares what's not working, and why? (I wonder if those .conf files are needed for basic setup at all anymore, besides some "special" hardware like my german keyboard is defined there.)
I just wanted to give you a brief quick solution (served on the silver platter for copy-paste) based on what I learned, how this is solved, and my primary idea of simply get things working - how is subordinate.

So, it works. Congrats!
 
Back
Top