You are not logged in.

#1 2023-06-20 07:46:15

gabtram
Member
Registered: 2023-04-11
Posts: 64

[Solved] X server: when insert xrandr command to switch screen

Hi to all,

i just need your opinion about onething:
I use a laptop with a hub (an hp hub with DP, some usb, network ).
I connect my external screen via DP to the hub.
I have my laptop on the right and the big screen in front of me, so each time i start i have to launch

xrandr --output DP-1-1 --mode 1920x1080 --left-of eDP-1  --auto

Now is it better to insert the command on my .xinitrc file where i start xmonad for my standard user or in xorg.conf or i don't know why?

Thanks

Last edited by gabtram (2023-07-20 12:12:25)

Offline

#2 2023-06-20 07:54:07

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

Offline

#3 2023-06-20 09:07:21

gabtram
Member
Registered: 2023-04-11
Posts: 64

Re: [Solved] X server: when insert xrandr command to switch screen

Hi installed the package,

then following this other topic: https://bbs.archlinux.org/viewtopic.php?id=279446, i tried to configure.
So i created a script in

/home/user/script/switch_monitor.sh

. The file is executable

#!/bin/bash

# Set the desired resolution and position for your external display
xrandr --output DP-1-1 --mode 1920x1080 --left-of eDP-1  --auto

Then i changed my .xinitrc file as follows

 
# Start x-on-resize
x-on-resize -c /home/user/script/switch_monitor.sh
#Xmonad start
exec xmonad
~

But on the startup, after inserting user and pass in the prompt, i have a black screen. Also when i launch

x-on-resize -c /home/user/script/switch_monitor.sh

i have blank screen.
Sorry i'm trying to do something but i lack some knowledge.

Thanks anyway
Bye

Offline

#4 2023-06-20 12:34:44

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

Re: [Solved] X server: when insert xrandr command to switch screen

x-on-resize acts when you change the configuration (ie. attach/remove the dock)
Also x-on-resize blocks, so either your xinitrc (which is btw. broken, last link below) is irrelevant (how do you start the session?) or "exec xmonad" is never reached.

To configure the outputs merely at the start of the server the best approach is defined by how global you want it to be.
If you're the only user or every user wants that exact configuration, https://wiki.archlinux.org/title/Multih … _xorg.conf is by far the best approach.
If you don't want the behavior to be global, run xrandr before xmonad in your xinitrc (do NOT fork the xrandr call) to have the outputs in place before the WM starts.

Offline

#5 2023-06-22 13:09:09

gabtram
Member
Registered: 2023-04-11
Posts: 64

Re: [Solved] X server: when insert xrandr command to switch screen

Hi Seth,

thanks for the specification. So this is correct

# Start x-on-resize
x-on-resize -c /home/user/script/switch_monitor.sh
#Xmonad start
exec xmonad

i deleted the lasta line

In my case i think the best approach is to insert

xrandr

before xmonad execution.

I'm configuring this machine to made also some live performance and so i will use my laptop with my docking with another screen (and i don't know if it could be an hdmi, DP or vga). Maybe i have to find a more general way.

But in the meantime thanks!!!

Offline

#6 2023-06-22 14:15:52

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

Re: [Solved] X server: when insert xrandr command to switch screen

So this is correct

seth wrote:

x-on-resize blocks, so either your xinitrc (which is btw. broken, last link below) is irrelevant (how do you start the session?) or "exec xmonad" is never reached.

xrandr

That will just print the current output configuration.

The server will, by default, enable all outputs present when it starts and any of this here isn't relevant for some one-off situation, but to automize regular configurations.
Ifyou're the only user of the system, use the xorg configlet.

Offline

#7 2023-06-23 16:52:12

gabtram
Member
Registered: 2023-04-11
Posts: 64

Re: [Solved] X server: when insert xrandr command to switch screen

Ok. It solve my issue!

Offline

#8 2023-06-23 18:43:51

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

Re: [Solved] X server: when insert xrandr command to switch screen

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#9 2023-06-26 10:57:12

gabtram
Member
Registered: 2023-04-11
Posts: 64

Re: [Solved] X server: when insert xrandr command to switch screen

Sorry,

i was thinking it worked but today i insert this configuration in my xorg.conf
To bring this

xrandr --output DP-1-1 --mode 1920x1080 --left-of eDP-1  --auto
Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 0 0
        InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

##Docking Display port conf
Section "Monitor"
    Identifier "DP-1-1"
    Option "PreferredMode" "1920x1080"
EndSection

Section "Monitor"
    Identifier "eDP-1"
    Option "PreferredMode" "1920x1080"
EndSection

Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "Intel Graphics"
    Monitor "DP-1-1"
    Option "Monitor-DP-1-1" "1920x1080_60.00"
    Option "Monitor-eDP-1" "1920x1080_60.00"
    Option "LeftOf" "eDP-1"
EndSection

Section "ServerLayout"
    Identifier "Layout0"
    Screen 0 "Screen0"
    Option "AllowNVIDIAGPUScreens"
    Option "Xinerama" "on"
EndSection
##End DP conf

But it not extend the screen but also allow me to use also the screen. Why?

Offline

#10 2023-06-26 13:18:17

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

Re: [Solved] X server: when insert xrandr command to switch screen

Because that's incorrect: https://man.archlinux.org/man/extra/xor … #Option~51 belongs into the Monitor section.
Also don't write a static server config, that's only gonna get you in trouble (and there's a bunch of cruft inside the particular one)

Section "Monitor"
    Identifier "DP-1-1"
    Option "PreferredMode" "1920x1080"
    Option "LeftOf" "eDP-1"
EndSection

Section "Monitor"
    Identifier "eDP-1"
    Option "PreferredMode" "1920x1080"
EndSection

is all that should™ be necessary.

Edit: if not, post an xorg log, https://wiki.archlinux.org/title/Xorg#General - this might be a hybrid system w/ reverse prime.

Last edited by seth (2023-06-26 13:19:09)

Offline

Board footer

Powered by FluxBB