You are not logged in.

#1 2021-10-08 15:45:10

peonerovv
Member
Registered: 2021-08-11
Posts: 34

[SOLVED] How to make configure monitors on startup?

Hello,

I've installed arch with dwm. I'm using a two monitor setup, with my laptop and a separate monitor. The separate monitor was setting as primary by default on startup of X, but when I fixed the screen tearing problem by adding vsync through /etc/X11/xorg.conf.d/20-intel.conf, the primary display was my laptops screen by default. I can still change it by running:
"
xrandr --output HDMI1 --auto
xrandr --output HDMI1 --primary
"
manually, but I couldn't find a solution on how to run these commands on the startup of X.
I tried modifying ~/.xinitrc with the commands above (with and without "exec" at the beginning), but it didn't help. Any help would by appreciated.

P.s. An option where the laptop screen is disabled would also work, since I'm not using it on my desktop. But it would be nice to have it active when the HDMI isn't connected

[edit] I didn't mention it in the O.P. at the beginning, but the screen would also set itself to a lower resolution.

Last edited by peonerovv (2021-10-08 18:17:08)

Offline

#2 2021-10-08 16:06:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,244

Re: [SOLVED] How to make configure monitors on startup?

/etc/X11/xorg.conf.d/11-monitor.conf

Section "Monitor"
	Identifier "HDMI1"
#	Option	"Enable"	"False" # defaults to true
	Option	"Primary"	"True"
EndSection

Section "Monitor"
	Identifier "eDP1"
#	Option	"Enable"	"False" # defaults to true
	Option	"Primary"	"False"
EndSection

Replace eDP1 w/ the actual output name from "xrandr -q"

I tried modifying ~/.xinitrc

Do you actually use startx/xinit?
Please post your xinitrc (attempts)

Offline

#3 2021-10-08 16:22:03

peonerovv
Member
Registered: 2021-08-11
Posts: 34

Re: [SOLVED] How to make configure monitors on startup?

seth wrote:

/etc/X11/xorg.conf.d/11-monitor.conf

Section "Monitor"
	Identifier "HDMI1"
#	Option	"Enable"	"False" # defaults to true
	Option	"Primary"	"True"
EndSection

Section "Monitor"
	Identifier "eDP1"
#	Option	"Enable"	"False" # defaults to true
	Option	"Primary"	"False"
EndSection

Replace eDP1 w/ the actual output name from "xrandr -q"

I tried modifying ~/.xinitrc

Do you actually use startx/xinit?
Please post your xinitrc (attempts)

I tried using your solution, but it didn't work. (with and without comments) (my laptop screen is called eDP1).

Here are the attempts, that I wrote in .xinitrc

exec dwm

exec xrandr --output HDMI1 --auto
exec xrandr --output HDMI1 --primary
exec xrandr --output HDMI1 --auto
exec xrandr --output HDMI1 --primary

exec dwm

(I also tried the same thing, but without "exec" before xrandr commands, just in case)

Last edited by peonerovv (2021-10-08 16:23:35)

Offline

#4 2021-10-08 16:57:51

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,244

Re: [SOLVED] How to make configure monitors on startup?

Nothing after the first "exec" line will be executed. So you'll have to run "xrandr --output HDMI1 --primary" first and finish w/ "exec dwm"
Also the xinitrc is broken (see the last link below) and if you could still login w/ an xinitrc that starts w/ "exec xrandr --output HDMI1 --auto" you're not using xinit to start the session itfp.

=> How do you login?

Offline

#5 2021-10-08 18:01:52

peonerovv
Member
Registered: 2021-08-11
Posts: 34

Re: [SOLVED] How to make configure monitors on startup?

I'm running X with "startx" in my .bash_profile.

Yes, putting "xrandr --output HDMI1 --primary" before "exec dwm" made it primary on startup, but I just realized that I forgot to mention that my resolution defaults to 1280x720 and mirrors the laptop display. In the meantime I tried putting

xrandr --output HDMI1 --primary --mode 1920x1200 --rate 59.95

but it doesn't seem to work. Again, I'm able to pass these commands manually, but not in the .xinitrc

Offline

#6 2021-10-08 18:15:29

peonerovv
Member
Registered: 2021-08-11
Posts: 34

Re: [SOLVED] How to make configure monitors on startup?

I just solved it.

I had to write

Section "Monitor"
    Identifier "HDMI1"
    Option "PreferedMode" "1920x1200"
    Option "Position" "0 0"
    Option "Primary" "true"
EndSection

Section "Monitor"
    Identifier "eDP1"
    Option "LeftOf" "HDMI1"
EndSection

In the /etc/X11/xorg.conf.d/10-monitor.conf. You recommended writing in 11-monitor.conf, instead of 10-monitor.conf. I don't really know what's the source of this error, but it works now!

Thanks for help!

Offline

#7 2021-10-08 20:20:42

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,244

Re: [SOLVED] How to make configure monitors on startup?

The index doesn't matter (unless there had been a 10-monitor.conf before) but your latest installment doesn't only (activate and) set the primary the output but also defines a mode for HDMI1 and a relative position for eDP1

This is btw. bogus: you set HDMI1 to 0x0 and then eDP1 left of it.
Since you'll always have the eDP with you but not necessariry the HDMI, I'd consider

Section "Monitor"
    Identifier "HDMI1"
    Option "PreferedMode" "1920x1200"
    Option "RightOf" "eDP1"
    Option "Primary" "true"
EndSection

Also your xinitrc is still broken and you should really fix that to avoid further issues (typically around an inactive session: mounting devices and shutting down w/o root permissions etcetc)

Offline

Board footer

Powered by FluxBB