You are not logged in.
I have 3 displays connected to my machine. One uses VGA and the other two are using HDMI/DP adapters. X starts the display with VGA at 640x480 and the position of the displays is always reset.
So I created an .xprofile file.
#!/bin/bash
xrandr --output VGA1 --mode 1920x1080
xrandr --output HDMI1 --right-of VGA1
xrandr --output HDMI2 --same-as HDMI1
But when I run it with xinit the i3 wm takes about 10 seconds to load and HDMI2 is the same as VGA1. When I run it manually inside i3 it works.
I also tried using the .xprofile file as the display-setup-script in LightDM with but that also takes about 10 seconds to load and afterwards LigthDM is kinda frozen. I'm able to enter my password but I can't really use LightDM since all animations only flicker and it only displays the first frame all the time. Also the only display that shows LightDM is VGA1.
I think the last line with the --same-as flag is the problem but how could I solve it without having to run the .xprofile always manually?
Last edited by Dun (2021-03-09 23:26:56)
Offline
Rather try https://wiki.archlinux.org/index.php/Mu … _xorg.conf and make sure that you don't fork the xprofile execution if you want to stick with it.
Are the outputs btw. connected to the same GPU?
Offline
Rather try https://wiki.archlinux.org/index.php/Mu … _xorg.conf and make sure that you don't fork the xprofile execution if you want to stick with it.
Thanks! With the configuration file it works without any issue. I had trouble to find an equivalent for --same-as until I realized I could simply use the position option to mirror the screens.
Modeline for VGA1 doesn't work though and I had to comment it out for the monitor to work. Is it an issue to have a monitor without that configuration line?
Are the outputs btw. connected to the same GPU?
I only have the onboard GPU of the CPU.
Offline
You do absolutely not have to add a modeline, certainly not a random one.
The system typically gets them via EDID (ie. your output says what resolutions and frequencies it supports)
Offline
You do absolutely not have to add a modeline, certainly not a random one.
The system typically gets them via EDID (ie. your output says what resolutions and frequencies it supports)
Thanks for the information.
But I have another problem I hadn't considered. When I resume the computer after suspension and VGA1 and HDMI1 are turned off (physically off but still connected), HDMI2 is at the position 0 0 and not 1920 0 anymore. I'm not sure how I could change my config so that won't happen anymore.
(0,0)-----------------+(1920,0)--------------+
| || |
| 1920 x 1080 || 1920 x 1080 |
| VGA1 || HDMI1 |
| || HDMI2 |
+---------------------++---------------------+
Section "Monitor"
Identifier "VGA1"
Option "PreferredMode" "1920x1080_60.00"
Option "LeftOf" "HDMI1"
Option "Position" "0 0"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "HDMI1"
Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120>
Option "PreferredMode" "1920x1080_60.00"
Option "Position" "1920 0"
Option "RightOf" "VGA1"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "HDMI2"
Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120>
Option "PreferredMode" "1920x1080_60.00"
Option "Position" "1920 0"
Option "RightOf" "VGA1"
Option "DPMS" "true"
EndSection
Last edited by Dun (2021-03-07 13:56:52)
Offline
"Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120>" is not a leal modeline, also remove those parts from the config entirely and rely on the EDID data.
Eg. the PreferredMode for VGA1 doesn't even exist.
Option "Position" "1920 0"
Option "RightOf" "VGA1"
You've a relative and an absolute postition. Pick one. This also holds for VGA1.
Post the cleaned up config and report whether the S3/wake issue remains with those.
Offline
Section "Monitor"
Identifier "VGA1"
Option "PreferredMode" "1920x1080_60.00"
Option "Position" "0 0"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "HDMI1"
Option "PreferredMode" "1920x1080_60.00"
Option "Position" "1920 0"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "HDMI2"
Option "PreferredMode" "1920x1080_60.00"
Option "Position" "1920 0"
Option "DPMS" "true"
EndSection
Sadly the issue persists. If I wake up HDMI2 is at position 0 0 instead of 1920 0.
Last edited by Dun (2021-03-07 13:25:37)
Offline
Remove the "PreferredMode", but that's likely not the cause.
I assume what happens is that HDMI2 shows up before VGA - can you swap their positions and does that survive an S3?
Offline
Yes removing PreferredMode has no effect. After the wakeup I'm able to change the position of HDMI2 back to 1920 0 with xrandr but it always changes back to 0 0 on the next wakeup.
Offline
What I meant was to use 'Option "Position" "1920 0"' for VGA1 and 'Option "Position" "0 0"' for HDMI2 (swap them) and whether that's stable against an S3
Offline
Now VGA1 is at 0 0 after the wakeup and HDMI2 stays at 0 0.
Offline
Meh.
They're either juggled at the suspend or at the resume - I don't see how you cold prevent that (if there's nothing left at 0x0, something will move there…)
You could go w/ a sleep hook, https://wiki.archlinux.org/index.php/Po … stem-sleep
You'll need proper DISPLAY and XAUTHORITY for your user/session, https://gist.github.com/AladW/de1c5676d93d05a5a0e1
Offline
Meh.
They're either juggled at the suspend or at the resume - I don't see how you cold prevent that (if there's nothing left at 0x0, something will move there…)You could go w/ a sleep hook, https://wiki.archlinux.org/index.php/Po … stem-sleep
You'll need proper DISPLAY and XAUTHORITY for your user/session, https://gist.github.com/AladW/de1c5676d93d05a5a0e1
Are these proper?
$ echo $DISPLAY
:0
$ echo $XAUTHORITY
/home/dun/.Xauthority
I can't run the script because fgconsole throws this
Couldn't get a file descriptor referring to the console.
and
pgrep -t tty1 xinit
returns error code 1. I also tried other terminals but no luck.
I created /usr/lib/systemd/system-sleep/monitor.sh.
#!/bin/sh
case $1/$2 in
pre/*)
;;
post/*)
# Waiting for a few seconds doesn't work
sleep 5
xrandr --output HDMI2 --pos 1920x0
;;
esac
The hook executes but HDMI2 is still a 0 0.
Offline
Are these proper?
"plausible"
pgrep -t tty1 xinit
returns error code 1
The actual script makes some assumptions about your session, in particular that it's started w/ xinit
EXIT STATUS
0 One or more processes matched the criteria. For pkill the process must also have
been successfully signalled.
1 No processes matched or none of them could be signalled.
2 Syntax error in the command line.
3 Fatal error: out of memory etc.
The hook executes but HDMI2 is still a 0 0.
W/o the proper environment, xrandr won't do anything (but yell an error about the display not being found)
Offline
The actual script makes some assumptions about your session, in particular that it's started w/ xinit
I was using LightDM and therefore didn't get the PID of xinit. I switched to xinit and ran the script (without fgconsole, just with pgrep -t tty1 xinit). The script executed without any errors but the xrandr command of the sleep hook still doesn't work.
W/o the proper environment, xrandr won't do anything (but yell an error about the display not being found)
How would a proper environment look like? I find little information on this topic that I understand.
Offline
The proper environment are the correctly exported DISPLAY and XAUTHORITY variables.
"Doesn't work" isn't a useful problem description.
Does *this* randr command fail or does any one (eg. selecting a different mode) fail?
Did you try to redirect the xrandr output into a file ("xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1")?
Offline
Did you try to redirect the xrandr output into a file ("xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1")?
Right I didn't think about that.
Does *this* randr command fail or does any one (eg. selecting a different mode) fail?
Yes it fails.
Can't open display
If I add -d :0 it's
No protocol specified
Can't open display :0
Changing the mode or the brightness of all displays outputs the same.
Offline
Post your current script and maybe echo out the values you actually obtain for DISPLAY and XAUTHORITY.
Offline
#!/bin/sh
case $1/$2 in
pre/*)
;;
post/*)
xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1
;;
esac
DISPLAY and XAUTHORITY aren't set, they echo an empty string.
Offline
Well, ensure to set them (and actually also pre-sleep a bit because we assume the output appears late)
Offline
Well, ensure to set them
You mean in the script like this? It still fails like before. They are now definitely set as I can echo them.
#!/bin/sh
case $1/$2 in
pre/*)
;;
post/*)
export $DISPLAY=":0"
export $XAUTHORITY="/home/dun/.Xauthority"
xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1
;;
esac
(and actually also pre-sleep a bit because we assume the output appears late)
I'm not sure what you mean by that. Do you mean I have to use the sleep command to wait for a few seconds pre sleep?
Offline
You mean in the script like this?
https://wiki.archlinux.org/index.php/En … _variables
export DISPLAY=:0
export XAUTHORITY=/home/dun/.Xauthority
Also read them in your active session to ensure that those are actually the required values.
I'm not sure what you mean by that.
…
sleep 5 # wait for the output
xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1
…
If this *still* all fails, run xrandr as your user
…
sudo -u dun xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1
…
Offline
I tried sleep and running it as a different user before but without the environment variables. I thought it would be enough to export them in .xinitrc. But finally it works now like this.
#!/bin/sh
case $1/$2 in
pre/*)
;;
post/*)
export DISPLAY=:0
export XAUTHORITY=/home/dun/.Xauthority
sleep 1
xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1
;;
esac
Thank you very much for the help and sorry for my incomprehention.
Offline
If this *still* all fails, run xrandr as your user
… sudo -u dun xrandr --output HDMI2 --pos 1920x0 > /tmp/randr.dbg 2>&1 …
I just wanted to highlight the sudo part is needed with a script I was having issues with. This is really valuable and I am glad I found it. Thanks for posting it.
Rlu: 222126
Offline