You are not logged in.

#1 2015-07-10 10:50:19

hungerfish
Member
Registered: 2009-09-13
Posts: 254

[SOLVED]xrandr called from startup script results in garbled display

Hi,
So I have a two monitor setup here. For 'reasons-tm' I want to move away from having a static configuration file in /etc/X11/xorg.conf.d. Using xrandr works just fine when used adhoc, but:
I wrote two small scripts which turn off (or on) my second monitor, and I want to call them from my window manager's startup script.
Calling them manually works fine by the way. This is one ofthe scripts:

 #!/bin/bash
DELL="DVI-1"
LG="DVI-0"
xrandr --output $LG --off --output $DELL --primary --mode 1920x1200 --pos 0x0

The problem is that when this gets called as my window manager starts, the result is a garbled screen.  (Wrong colors, distorted background image)
Example startup script:

#!/bin/bash
lg-off &
...more stuff...
dwm

This does not only happen with dwm, that is just an example. When (and from where) should I be turning off my second monitor to avoid this?

Last edited by hungerfish (2015-07-15 08:03:46)


Beetles and bacteria are vastly more successful than humans in terms of survival.

Offline

#2 2015-07-13 01:45:33

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [SOLVED]xrandr called from startup script results in garbled display

Personally, I would call the script after your windows Manager...

Offline

#3 2015-07-13 11:58:16

hungerfish
Member
Registered: 2009-09-13
Posts: 254

Re: [SOLVED]xrandr called from startup script results in garbled display

Sadly that doesn't *always* work, meaning it works fine with most WMs but not so well with others, hence me trying to find a usable workaround.
I've since discovered that this (colour distortion) also happens when I add the xrandr call directly to /etc/lightdm/lightdm.conf:

display-setup-script=xrandr --output DVI-0 --off

Also, I've tried to just disable the 'DVI-0'-monitor via configfile in /etc/X11/xorg.conf.d  by having an appropriate '30-monitor.conf' file:

Section "Monitor"
    Identifier  "DVI-0"
    Option      "Enable" "false"
    #Option      "Ignore" "true"
EndSection

The 'Enable' option seems to have no effect.
When using the 'Ignore' options the monitor stays off, just without the ability to switch it on if needed which is not what I want.

Basically I want to be able to boot with both monitors physically connected, have the login-manager use only my primary display and disable the secondary display.
From there I should have every WM working in single-head mode, unless I decide I need both monitors at which point I could just 'flick' the secondary to on and be happy.
Initially I though it would be easier to forgo  the login-manager-step and turn off the second monitor when starting a WM, but as this turns out to be 'broken' in some way, I guess it matters little...

Any ideas?
I've also tried to use a Serverlayout configuration (like in the Arch Xorg wiki), but that just turns off both screens for some reason..


Beetles and bacteria are vastly more successful than humans in terms of survival.

Offline

#4 2015-07-14 14:34:24

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [SOLVED]xrandr called from startup script results in garbled display

You could try adding a sleep command to delay your script and allow WM to finish its loading ...

#!/bin/bash
...more stuff...
dwm # No '&' to allow for process to finish first before moving onto next command
sleep 5 # adjust to smallest amount that consistantly works
lg-off

Offline

#5 2015-07-15 08:03:30

hungerfish
Member
Registered: 2009-09-13
Posts: 254

Re: [SOLVED]xrandr called from startup script results in garbled display

Ha, it seems the most simple solutions are often the best! I commend you Sir & please ignore that plank of wood before my head...

I ended up adding 'sleep 2' (2secs seem to work in my case) to the 'lg-off' script and now call this from my WM-startup-script BEFORE anything else there runs.
I no longer call the script from lightdm, as this just causes the monitor to cycle between on/off states during login/logout. I also retained a '/etc/X11/xorg.conf.d/30-monitors.conf' file which defines preferred mode & physical layout of the two monitors which at least makes lightdm work ok.
It still would be nice to 'solve' this by getting the xserver to accept that 'Enable' option, but I can't be bothered to go digging. Thanks for the pointer!


Beetles and bacteria are vastly more successful than humans in terms of survival.

Offline

#6 2015-07-15 12:02:20

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [SOLVED]xrandr called from startup script results in garbled display

Glad you got this working smile

P.S. have you tried instead of enable

Option "Disable" "yes"

or

Option "Disable" "true"

Last edited by Malkymder (2015-07-15 12:40:33)

Offline

#7 2015-07-15 14:28:44

hungerfish
Member
Registered: 2009-09-13
Posts: 254

Re: [SOLVED]xrandr called from startup script results in garbled display

Glad you got this working

Me too, but I've since realised, that because I'm also calling '/usr/lib/mate-settings-daemon/mate-settings-daemon' from my startup script, I can just configure mate to only run on one screen, which then gets applied to whatever session I call the settings-daemon from... so much confusion wink

Regarding monitor.conf, I did try various options and configurations, but nothing worked. It's stated quite clearly in 'xorg.conf.d(5)' :

Option "Enable" "bool" This optional entry specifies whether the monitor should be turned on at startup.  By default, the server will attempt to enable all connected monitors.  (RandR 1.2-supporting drivers only)

Beetles and bacteria are vastly more successful than humans in terms of survival.

Offline

Board footer

Powered by FluxBB