How do I set up a login script, to run xrandr?
I'm using a 2 screens layout which is a bit similar to yours, mine is a regular screen on the right and a portrait-oriented one on the left. With my setup I have X working perfectly on my 2 screens.
Here's my proposition for your own case (hard to test as I don't have the same screens and don't have 3 screens) but that should be enough for you to get a working X setup.
Put the following files in /etc/X11/xorg.conf.d/
30-screen-dport0.conf
30-screen-dport1.conf
30-screen-dport2.conf
with the following content :
30-screen-dportcenter.conf
Section "Monitor"
Identifier "DisplayPort-0"
Option "Primary" "true"
Option "PreferredMode" "3840x2160" # Adapt this if you resolution is not the same
Option "Position" "1200 0"
EndSection
Section "Screen"
Identifier "DPC"
Device "nVidia" # here you choose your driver
Monitor "DisplayPort-0"
EndSection
30-screen-dportleft.conf
Section "Monitor"
Identifier "DisplayPort-1 "
Option "LeftOf" "DisplayPort-0"
Option "Rotate" "left"
Option "PreferredMode" "1920x1200"
Option "Position" "0 0"
EndSection
Section "Screen"
Identifier "DPL"
Device "nVidia"
Monitor "DisplayPort-1"
EndSection
30-screen-dportright.conf
Section "Monitor"
Identifier "DisplayPort-2"
Option "RightOf" "DisplayPort-0"
Option "Rotate" "right"
Option "PreferredMode" "1920x1200"
Option "Position" "5040 0" # 1200 + 3840
EndSection
Section "Screen"
Identifier "DPR"
Device "nVidia"
Monitor "DisplayPort-2"
EndSection
90-serverlayout.conf
Section "ServerLayout"
Identifier "Main"
Screen 0 "DPL"
Screen 1 "DPC"
Screen 2 "DPR
EndSection
The coordinates of the Xserver works the following way
0 X
+ -----------------> X-axis
|0
|
|
|
|
|
| Y
V Y-axis
The nVidia identifier is a reference to a video card defined in a file called
20-nvidia.conf
Section "Device"
Identifier "nVidia"
Driver "nouveau"
Option "AccelMethod" "sna"
Option "GLXVBlank" "true"
# Need to flag this as only referring to one output on the card
Screen 0
EndSection
I use a user-land systemd service (full path = $HOME/.config/systemd/user/set-display.service
) to handle a similar situation on my QEMU VMs that use XFCE and do not automatically fill the screen (cut short due to conky):
[Unit]
Description=Set Display Resolution
[Service]
ExecStartPre=/bin/sleep 5
Type=oneshot
ExecStart=/usr/bin/xrandr --output Virtual-0 --mode 1499x996
[Install]
WantedBy=default.target
I use the sleep command to make sure that the DE is fully loaded; my VMs on SSDs were always fine with 5 seconds or less, the HDD ones sometimes needed more. Just create a script that runs both of your xrandr commands, substitute it on the ExecStart= (something like ExecStart=/path/to/your/script
), then enable it (systemctl --user enable set-display
).
UPDATE: testing as system service on Debian Buster did not work, even when running the service manually after logging in (tried as root and normal user).