Cannot set external monitor as primary in Gnome 42 Xorg

Hello,

I would like to set my external monitor as primary in gnome 42 with xorg session.
In Wayland that is working as a charm but in xorg is not.

I go to settings → displays → Primary Display but when I select the external monitor nothing happens.

at the moment the only way to set the monitor as primary is to run the following command at startup

xrandr --output "HDMI2" --primary

I tried put this code in ~/.bashrc but is not an elegant solution

dname="$(xrandr | grep -Po '(HDMI2).+(?= connected)')"
if [ ! -z $dname ]; then
    xrandr --output "${dname}" --primary
fi

I did some search in the forum and on google but I didn’t find anything related to this specific issue

I now see an open issue on gnome

1 Like

bashrc is not the right place for X related code.
Use ~/.xprofile instead, if you use GDM, SDDM, LightDM etc.

Good find!
Have you tried for a workaround, as implied in that report?
When you change the Primary setting, do another fake (or not) modification to that monitor and Apply. I am not sure this would work (not clear to me in the comments… :person_shrugging: ).

Thanks, I din’t know about ~/.xprofile
I wrote the following code inside:

xrandr --output "HDMI2" --primary 

touch /home/r4funk/hello

I see the file created but the primary display is not set as primary…
should I put a sleep?
When I run the command in a terminal it works.

I tried any possible workaround with the Display menu but also other option are change and I click apply the primary display is not change

Was it also working as expected when in .bashrc?

You should try using a bash script and autostart it with Gnome Autostart.

I took the weekend for doing more test and looks like is working now (without any change)
Probably there is something in my little code that prevent it to work in some case. I will have a look when I have time.

Anyway thanks for pointing me in the right direction.
I hope the bug is fixed soon in gnome so I won’t need those kind of workaround.

I’m pretty sure this is a bug. I also can’t/couldn’t yesterday when I tried also.