0

I have an xrandr command that sets up my monitors exactly as required (different scales to deal with Ubuntu's extremely limited HDPI support at current):

xrandr --fb 7040x2160 --output DP1 --mode 1920x1080 --pos 0x0 --scale 2x2 --output eDP1 --mode 3200x1800 --pos 3840x180 --scale 1x1

If I run this in a terminal after logging in it works perfectly. It also works via Startup Applications as seen in these answers: 1, 2, and 3 (works without the sleep). I get a configuration that looks like this:

Screen 0: minimum 8 x 8, current 7040 x 2160, maximum 32767 x 32767
eDP1 connected primary 3200x1800+3840+180 (normal left inverted right x axis y axis) 294mm x 165mm
   3200x1800     59.98*+  47.99  
   2880x1620     60.00  
   2560x1440     60.00  
   2048x1536     60.00  
   1920x1440     60.00  
   1856x1392     60.01  
   1792x1344     60.01  
   2048x1152     60.00  
   1920x1200     59.95  
   1920x1080     60.00    59.93  
   1600x1200     60.00  
   1680x1050     59.95    59.88  
   1600x1024     60.17  
   1400x1050     59.98  
   1600x900      60.00  
   1280x1024     60.02  
   1440x900      59.89  
   1280x960      60.00  
   1368x768      60.00  
   1360x768      59.80    59.96  
   1152x864      60.00  
   1280x720      60.00  
   1024x768      60.00  
   1024x576      60.00  
   960x540       60.00  
   800x600       60.32    56.25  
   864x486       60.00  
   640x480       59.94  
   720x405       60.00  
   640x360       60.00  
DP1 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
   1920x1080     60.00*+  50.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1600x1200     60.00  
   1680x1050     59.88  
   1280x1024     75.02    60.02  
   1440x900      74.98    59.90  
   1280x960      60.00  
   1280x800      59.91  
   1152x864      75.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
DP2 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

If I run exactly the same command anywhere in the startup process, I either get a garbled configuration in which my framebuffer size is incorrect (with screens placed over the top of each other) or no effect at all. Places I've tried are .xprofile, lightdm configuration (called with display-setup-script, greeter-setup-script, and session-setup-script).

I've logged verbose output from the command, and all the time it says it's set the correct values, but the output on my screens and querying xrandr afterwards obviously says otherwise. How can I configure my screens further up the chain (at least so that the greeter is displayed correctly)? Given the X server is initialised well before then, is there a way to get the xrandr configuration commands to stick?

Edit note: question now focuses on the root of the problem "configuring monitors prior to once logged in"

btalb
  • 596
  • 1
    Very strange it doesn't work from lightdm , but I think what also happens is that during login , Unity tries to set up the screen by itself, so that might be another things that breaks. If your login screen doesn't require configuration, and only needed for Unity session, would you consider adding that command to startup applications so that it runs automatically after you login ? – Sergiy Kolodyazhnyy Nov 05 '16 at 03:54
  • Worked perfectly there. I think you're definitely correct about Unity jumping in there and trying to apply it's own screen configuration. Thanks for the solution! Ideally, I would like to apply it for the greeter as well, but unless there's an easy way to stop Unity from interfering, this may have to do – btalb Nov 05 '16 at 05:03
  • I guess I'll post it as an answer then – Sergiy Kolodyazhnyy Nov 05 '16 at 05:27
  • 1
    Possible duplicate of "Startup Applications" not working and http://askubuntu.com/questions/637911/how-to-run-xrandr-commands-at-startup-in-ubuntu – Jacob Vlijm Nov 05 '16 at 06:27
  • Rephrased. Those "possible duplicates" only half answer what I am trying to achieve. – btalb Nov 05 '16 at 10:40
  • 1
    Running the command during log in always gives an unpredictable result, since you do not exaxtly know which local setting is applied and when exactly, and where they possibly clash with your command. The only adviceable procedure is to do it after the login process has finished. – Jacob Vlijm Nov 05 '16 at 22:57

1 Answers1

1

My guess is that during login process, Unity tries to set up the screen by itself, so that might be one of the things that breaks. If your login screen doesn't require configuration, and only needed for Unity session, would you consider adding that command to startup applications so that it runs automatically after you login. That way unity applies its changes, but then you override them with your own command.

What I also would recommend is to use a modified version of your command:

bash -c 'sleep 3 && xrandr --fb 7040x2160 --output DP1 --mode 1920x1080 --pos 0x0 --scale 2x2 --output eDP1 --mode 3200x1800 --pos 3840x180 --scale 1x1'

That way there's sufficient delay for Unity to apply its changes, and then you run your own

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497