6

I would really like to be apply my display settings (currently managed with xrandr) on an automated basis after plugging in my display. I assumed this could be done with a Bash script, however I have not found a way to get a handle on display settings from the terminal.

After connecting an HDMI external monitor, I have to use the 'Display Settings' GUI to activate and configure the monitor. This would not be a big deal, except checking 'Use this output' doesn't always take the first time (the 'keep this configuration' dialog pops up, but the display remains inactive), I have to use the 'advanced' settings to rearrange the two displays, and this has to be done every time I wake the machine from sleep.

I wanted to look into scripting some of these settings with xrandr, but I can't get xrandr commands to work on the HDMI display.

$ xrandr --output HDMI1 --mode 1920x1080

..flashes the built in display and pops up the Display settings GUI (if 'Configure new displays when connected' is checked in the GUI, flashes output and does nothing if not).

xrandr -d :0 output HDMI1 --auto

does the same thing. I've also tried the 'arandr' GUI. Not sure what commands it runs, but they do the same thing also.

  • Xubuntu 15.04
  • xfce 4.12
  • Lenovo Yoga 13 intel i5
  • Intel HD Graphics 4000
  • Samsung 27" SyncMaster SA550 external display

xrandr output:

Screen 0: minimum 8 x 8, current 3520 x 1346, maximum 32767 x 32767
LVDS1 connected primary 1600x900+0+446 (normal left inverted right x axis y axis) 294mm x 166mm
   1600x900       60.1*+
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1920x1080+1600+0 (normal left inverted right x axis y axis) 509mm x 286mm
   1920x1080      60.0*+   50.0     59.9  
   1680x1050      59.9  
   1280x1024      60.0  
   1440x900       59.9  
   1280x800       59.9  
   1152x864       75.0  
   1280x720       60.0     50.0     59.9  
   1024x768       70.1     60.0  
   800x600        60.3     56.2  
   720x576        50.0  
   720x480        60.0     59.9  
   640x480        66.7     60.0     59.9  
   720x400        70.1  
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

Edit: xrandr output before adjusting with gui:

(Not sure if it's relevant, but if I plug in the display and don't configure immediately, the xfce4-display-settings guis/processes begin to pop up every few seconds endlessly. The power management 'Blank after x minutes' kicked in yesterday with a different hdmi display plugged in and there were about 50 'Displays' windows open when I resumed use.)

Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
LVDS1 connected primary 1600x900+0+0 (normal left inverted right x axis y axis) 294mm x 166mm
   1600x900       60.1*+
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected (normal left inverted right x axis y axis)
   1920x1080      60.0 +   50.0     59.9  
   1680x1050      59.9  
   1280x1024      60.0  
   1440x900       59.9  
   1280x800       59.9  
   1152x864       75.0  
   1280x720       60.0     50.0     59.9  
   1024x768       70.1     60.0  
   800x600        60.3     56.2  
   720x576        50.0  
   720x480        60.0     59.9  
   640x480        66.7     60.0     59.9  
   720x400        70.1  
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
  • Try lxrandr . This gui app allows you to save configuration as a script, which you can later add as Startup Application to run on each graphical login. Unfortunatelly, right now I'm using only single screen , so can't help you much – Sergiy Kolodyazhnyy Jun 8 '15 at 9:28
  • I'm working on doing the same thing with my second display right now. Can you give us your output of xrandr or xrandr -q? – Michael Hoffmann Oct 6 '15 at 15:07
  • I assume this is the output of xrandr after you made the setup via GUI. Could you add the output before? (but with monitor connected)? – Jacob Vlijm Oct 17 '15 at 18:05
  • 1
    @JacobVlijm I just figured out that running xrandr --auto will enable the HDMI display. Can you repost your answer that showed the syntax for configuring the offsets? – HowlingFantods Oct 20 '15 at 19:50
  • Sure, I just did right now :) – Jacob Vlijm Oct 20 '15 at 19:51
2

After setting the screen via GUI

In the line (in the output of xrandr after you set the screen via GUI):

HDMI1 connected 1920x1080+1600+0 (normal left inverted right x axis y axis) 509mm x 286mm

the position of the second screen (HDMI1) is defined top-allined, at he the right of your main screen (LVDS1): 1920x1080+1600+0, as explained here.

Before setting the screen via GUI

The definition of the position of your right screen seems to be missing for some reason.

I am not sure what causes the behaviour, might be a minor incompatibility, but it should be fixed with the command:

xrandr --output HDMI1 --pos 1600x0

Which will position the second screen at the right of the main screen, top- allined.

  • Running the command doesn't seem to have any effect. The other difference I notice before and after positioning with the gui is '509mm x 286mm'...is that relevant? – HowlingFantods Oct 19 '15 at 23:07
1

I had the same issue, but solved it. Made an keyboard shortcut to run xrandr command wich looks like this: xrandr --output HDMI-1 --auto --output VGA-1 --off and, you guessed it, reverse for the monitor to work :)

1

The trick turned out to be running the xrandr --auto command after the second display is plugged in.

After running that command the display comes on and is configurable with additional xrandr commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.