Using xrandr with external display ports 11


I've noticed a lot of searches on xrandr in my blog stats and have been wondering what the problem is.  Xrandr is a command line tool for enabling or disabling multiple display ports on your system as well as setting display resolution and even rotation.  You would use it, for example, to enable tv-out or an external monitor while also setting its relative position from the current display and the resolution to use.  The tool is the user end point for the RandR extension to the X.org server.

On my systems I set up a few simple shell scripts to enable specific modes and then disable them when I'm done with that mode.  My acer aspire laptop, which uses an Intel i915GM chipset, has external VGA and TV-Out ports.  The VGA output is used for two purposes.  At home I have an external LCD that I use side by side with the laptop monitor to give me extra screen space to work with.  At work or when I give presentations at local user group meetings or conferences I use the external vga port to connect to a projector.

Finding available ports

If you aren't sure what ports are available you can run xrandr to query the system:

xrandr -q

This will show you the display ports that the X server knows about. You must run this and all other xrandr commands from the desktop.  You can't, for example, login through ssh from another machine to view the available ports.  This violates X authentication (you can do it if you run ssh -X, possibly, but I'm not going to get into X authentication issues at this point).  The output from this command will look something like this:

$ xrandr -q
Screen 0: minimum 320 x 200, current 2560 x 800, maximum 2560 x 2048
VGA connected 1280×768+1280+0 (normal left inverted right x axis y axis) 370mm x 222mm
1280×768       59.9*+
1280×960       60.0
1280×720       75.0     60.0
1024×768       75.0     72.0     70.1     60.0
832×624        74.6
800×600        72.2     75.0     60.3     56.2
640×480        75.0     72.8     75.0     66.7     59.9
720×400        70.1
LVDS connected 1280×800+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
1280×800       60.0*+
1024×768       60.0
800×600        60.3
640×480        59.9
TV disconnected (normal left inverted right x axis y axis)

This tells me that the X server knows about the external VGA port, the laptop's LCD (LVDS) and a TV-out port.  It even knows the TV port has nothing connected to it at the moment.   In this output the settings for the VGA port and laptop LCD screen are known because I'm using them right now, meaning I've already gone through the process I'm about to describe.

External VGA

The external LCD configuration is static.  The display is made by Westinghouse and has a maximum resolution of 1280×768.  The laptop has a maximum display of 1280×800.  To enable both displays at their maximum resolution and configured them side by side (so the mouse moves from the laptop on the left to the external LCD on the right:

xrandr –output LVDS –mode 1280×800 –output VGA –mode 1280×768 –right-of LVDS

LVDS is the laptop screen.  It gets set first so that the –right-of option will apply to the last –output defined (re: the VGA output).  That's all there is to it.  To get back to normal, I disable the external monitor:

xrandr –output VGA –off
xrandr –output LVDS –mode 1280×800 –rotate normal

The rotate option in the second line is there because somtimes I rotate the laptop monitor manually and forget to put it back when I reset the configuration, which leaves me with a single monitor rotated 90 degrees.  It's kinda hard to work that way.

Note that this configuration only works with my intel-based chipset if I've configured the X server properly.  You can see plenty of discussion of this issue in other posts in my blog.

The laptop hardware is interesting in that if the external VGA is plugged in when the laptop boots then only the external monitor displays anything – at least during the boot.  Once X gets started then I have a cloned display on both LCDs showing the same thing.  This is what I get up to the gdm login screen.  Once I login the laptop display becomes the master and the external VGA is not on.   To get it back on I run my little script with the above command.

The fact that the external monitor is on to start with but then off once I logged in used to confuse me a little.  I used to think I would have to unplug the external monitor every time I rebooted, but that really isn't the case.  Everything is how it should be once I'm logged in through gdm.

External projector

Connecting to an external projector is a little different.  Many of these will auto-configure using standard resolutions of 800×600, 1024×768 or even higher.  Some are smart enough to handle odd resolutions as well.  But just because they handle that resolution doesn't mean they display it very well.  My experience has been that 1024×768 is about the best you'll get without having lots of time to fiddle with the projector – something you don't often have when giving a presentation.

For most of my presentations I like to create a new user and run the presentation from that user.  The reason for this is to avoid accidently falling back to my well tuned desktop or shell configurations when explaining how to do something.  From this new users desktop I configure panel launchers under gnome to run xrandr scripts to enable the external projector.  The commands are essentially the same but I fall back to smaller screen sizes on the projector:

xrandr –output LVDS –mode 1280×800 –output VGA –mode 1024×768 –right-of LVDS

The caveat to this one – which unfortunately I stumbled upon right as I was about to give my last presentation – is that OpenOffice didn't see this as two screens but rather one big screen.  Under my own login OpenOffice saw this as two screens.  I have yet to determine why this happened.   Why this is important comes from how you handle your OpenOffice presentation.  With OpenOffice 3 (which comes with fedora 10) you can have one screen (the external projector) showing the slides while the other screen shows the notes you prepared for each slide.  It's quite slick.  It just didn't work when I gave the presentation, but it worked at home when I rehearsed it.

Note that this may have been that I didn't have OpenOffice configured properly for the new user to use both screens as independent screens.  See what you discover when you don't depend on your regular login?

External TV

The external TV port is an S-Video port.  This port is outbound only, meaning that you can use your laptop to display to a TV but you can't use your TV to display on your laptop.  That would be nice, since our big screen TV projector pooped out at christmas.  But that's a story for another time.

Most TVs display video quite well at 640×480 and maybe 800×600. Newer TVs might display higher resolutions, but don't count it.  Higher resolutions are often required to get decent text output on the TV such as on screen displays like in mythtv, but the only way to know what works best is to try it out on your TV.  MythTV offers a number of options for setting the size and quality of the text you see in the on-screen guides.

I haven't used the TV-out port in some time and don't want to disable the external VGA, drag the laptop downstairs and hook up the s-video to test it again.  If I get around to that sometime soon I'll post an update on how it's working.

Left, Right, Top, Bottom

One set of options to xrandr that is important are the options that position a second display relative to the first.  You can specify positions left, right, above and below (as opposed to top and bottom) for the second display.  This becomes important for configurations like mine.  I currently have the external VGA set left-of the laptop LCD so I can drag my mouse side to side.  The two screens function as one large screen for me.

However, this configuration also forces me to disable acceleration features in the X.org intel driver because the combined width of the two displays is large than 2048, and 2048 is the maximum I can use and still utilize acceleration features of the driver.  I've opted to disable those features in order to get the full 2560 width (1280 for the LCD, 1280 for the external VGA) in a virtual space.  Virtual is meaningful to the driver but to the end user it's still one big screen spread across two monitors.

How you configure your monitors (left, right, etc.) may also determine some of the features you'll be able to use.  This is known to be an issue on Intel chips prior to the i945GM, I believe.  Newer model chips (higher version number) are not limited by this and can still provide acceleration at the size screens I'm using.

Summary

There are a lot of other things you can do with xrandr but this covers the basic use most home users will require.   If you have questions on the other options, post a comment.  I'll see what I can find out for you.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

11 thoughts on “Using xrandr with external display ports

  • Massimo

    Hi,
    thanks for your post. Are you sure about xrandr command?
    The first one is working:
    ///////—–///////
    [root@shrek ~]# xrandr -q
    Screen 0: minimum 320 x 200, current 1280 x 800, maximum 1280 x 1280
    VGA connected (normal left inverted right x axis y axis)
    1024×768 60.0
    800×600 60.3 56.2
    640×480 59.9
    LVDS connected 1280×800+0+0 (normal left inverted right x axis y axis) 290mm x 180mm
    1280×800 60.0*+
    1024×768 60.0
    800×600 60.3
    640×480 59.9
    TMDS-1 disconnected (normal left inverted right x axis y axis)
    //////—–/////

    but for the other ones, it seems that something is wrong;
    xrandr –-output LVDS –-mode 640×480 –-output VGA –-mode 640×480 -–right-of LVDS
    (as you can see, it is seems that we have to use “–” instead of “-“, but nothing happen. I always get the output of the –help command, that is something is wrong with this command.

    Any idea? I’m using Fedora 10 i386
    Thanks,
    M

  • mjhammel Post author

    First, you’re right, that is two dashes and not one that precede each option. The font I used turned those into a single dash, or at least made it look that way. Sorry about that.

    Second, I don’t see anything specifically wrong with your command line. It’s possible the options are not supported by the version of the server you’re running. Try running xrandr -v and make sure it returns Server reports RandR version 1.2. I noticed recently on the xorg mailing list that it’s also possible the server may report that it supports one level but the actual driver does not, though I believe that may be limited to the next version of the RandR extension. If you’re using a version of the the Xorg server from the GIT repositories then this may be the problem. However, the stock xorg packages in F10 should not have this problem.

    Since I can see no problem with the command line my suggestion would be to try and enable the external port manually step by step. So try this first:

    xrandr –auto

    This should enable the VGA port in it’s preferred mode. The port should be connected to a monitor (which it appears to be from your xrandr -q output). Whether this works or not, try this:

    xrandr –output VGA –off
    xrandr –output LVDS –mode 640×480

    That will test if the LVDS output can be set to the desired mode. If that works, then try the original command without setting its location:

    xrandr –output LVDS –mode 640×480 –output VGA –mode 640×480

    If that works then obviously the problem is with the –left-of portion of the command. You can try using the –pos XxY option instead to position the second display, though I’ve never used that option. There are a few other options you may be able to experiment with – take a look at the xrandr man page for details: man xrandr

    Hope that helps.

  • roystreet

    Hi I have a monitor I also plug into my laptop. The resolution for my monitor is 1920×1680. When I plug this in using ubuntu 9.04 it will give me the right resolution available, but it stops compiz from working correctly. So I don’t get some of the special effects & I can’t use the Avant bar at the bottom of my screen. Do you know of a way I can fix this? I was reading somewhere about making one of the monitors on the bottom instead of extending it on the side…Do you think this would work? When the resolution is much lower or if it’s just my laptop, compiz works great!

    Thanks,
    ~roystreet

  • mjhammel Post author

    On the surface this sounds like the virtual resolution limit problem with the Intel drivers. You don’t mention it but I’m assuming your laptop has an Intel graphics chip in it. Anyway, when you use a resolution over 2048 x2048 (ie over 2048 in either direction) the 3D acceleration is lost so Compiz can’t do its eye candy. The vertical limit is the same as the horizontal limit so unless your external monitor is teeny-tiny I don’t think aligning the monitors vertically is going to let you use Compiz when using dual monitors at full resolution. Essentially, the best you can do and get compiz working is 1024×1024 on both monitors.

    The Intel drivers were undergoing an architectural change when I wrote the original blog post and I haven’t checked recently if they’ve completed the update. Even if they have it may be some time before distributions begin shipping it.

  • smitchell

    Hi, I have 2 problems getting xrandr 1.3 to work correctly.
    I have 3 Dell 30" 3008 monitors in vertical orientation and a newly acquired radeon HD R6990 video card with 4 mini-dp and 1 dual link dvi-d port.  Running Slackware 13.37 and kernel 2.6.37.6 compiled with option for kernel messages to be rotated for vertical displays. 
    xrandr detects the monitors as individual screens, and falsely reports the monitors as:
    left, 2560×1600
    middle 1920×1200
    right, 1280×800
    second problem, once I get the displays
    resolutions working correctly (2560×1600 each)
     is mapping them all as one big X screen, using
     coordinates on a virtual display (using 0 0, 1600,0, 3200 0).
    right now they are cloned, with resolutions getting smaller left to right.
    My xorg.conf is:
    Section "ServerLayout"
        Identifier     "aticonfig Layout"
        Screen      "aticonfig-Screen[0]-0"
    EndSection

    Section "Module"
    EndSection

    Section "ServerFlags"
        Option        "Xinerama" "off"
    EndSection

    Section "Monitor"
        Identifier   "aticonfig-Monitor[0]-0"
        Option        "VendorName" "ATI Proprietary Driver"
        Option        "ModelName" "Generic Autodetecting Monitor"
        Option        "DPMS" "true"
    EndSection

    Section "Device"
        Identifier  "aticonfig-Device[0]-0"
        Driver      "fglrx"
        BusID       "PCI:8:0:0"
    EndSection

    Section "Screen"
        Identifier "aticonfig-Screen[0]-0"
        Device     "aticonfig-Device[0]-0"
        Monitor    "aticonfig-Monitor[0]-0"
        DefaultDepth     24
        SubSection "Display"
            Depth 24
            Modes "2560×1600"
            Virtual 5760 5760
        EndSubSection
    EndSection

    I set the Virtual setting to very large to troubleshoot–since this video card has 4 GB of ram that should not cause a problem, I think.
    Have you any idea why my video card thinks I have these different resolutions or what to do to correct it?
    One that is solved, do you have an idea what my xorg.conf should look like for the three monitors?  Should I have a section for each monitor?
    In case it matters, the left one is connected by a displayport cable dp and a mini-dp adapter, the middle with a dp to mini-dp cable, and the right by a dual-link dvi-d cable and dvi-d to mini-dp adapter.
    Smitchell
     

  • mjhammel Post author

    My first guess is that the fglrx driver doesn’t know how to handle that video hardware in that way. Not every driver works properly with xrandr. The intel driver used to have that problem but has been updated to better support it over the years. Also, the driver may be limited to the total resolution that it can handle. So maybe the total screen space you *could* have is more than the card can support. I’ve had that problem in the past with older video hardware with external monitors

    You definitely need a section for each monitor. It’s unclear to me, given the advances in X.org, whether you actually *have* to have an xorg.conf anymore. But it probably won’t hurt to create one at least for testing.

    I don’t think it matters what physical connections you have. The card should abstract that for the driver.

    Sorry this isn’t more helpful. I haven’t played with this stuff in quite a while. Good luck.

  • seanthebean

    Thanks a lot! I was having a little trouble figuring out how to use xrandr from the man page, but your examples got me started easily!
    Only issues I had are that the two hyphens ("- -", but without the space), gets displayed on this page as a dash ("–"), so copy/pasting directly into the terminal does not work.
    And my outputs are LVDS1, VGA1, etc, not LVDS, VGA, etc – I'm guessing that varies by system.
    Anyway, thanks again for the help!

  • TheTubaGeek

    I have LinuxMint Cinnamon installed on my laptop and recently acquired a docking station for it.

    It has a DVI port, and I decided to connect my ASUS wide-screen monitor to it. Unfortunately, it has not given me a display yet. My ultimate goal is to have this screen and my laptop working as independent displays.

    Below are the results of running inxi -Fx:
    System:    Host: Kanga Kernel: 3.8.0-19-generic i686 (32 bit, gcc: 4.7.3) Desktop: Gnome Distro: Linux Mint 15 Olivia
    Machine:   System: TOSHIBA product: TECRA A8 version: PTA83U-02V02C
               Mobo: TOSHIBA model: Portable PC version: Version A0 Bios: TOSHIBA version: Version 1.50 date: 08/30/2006
    CPU:       Dual core Intel CPU T2300 (-MCP-) cache: 2048 KB flags: (nx sse sse2 sse3) bmips: 6649.96 
               Clock Speeds: 1: 1000.00 MHz 2: 1000.00 MHz
    Graphics:  Card: Intel Mobile 945GM/GMS 943/940GML Express Integrated Graphics Controller bus-ID: 00:02.0 
               X.Org: 1.13.3 drivers: intel (unloaded: fbdev,vesa) Resolution: 1280×800@60.0hz 
               GLX Renderer: Mesa DRI Intel 945GM x86/MMX/SSE2 GLX Version: 1.4 Mesa 9.1.7 Direct Rendering: Yes
    Audio:     Card: Intel NM10/ICH7 Family High Definition Audio Controller driver: snd_hda_intel bus-ID: 00:1b.0
               Sound: Advanced Linux Sound Architecture ver: k3.8.0-19-generic
    Network:   Card-1: Intel 82573L Gigabit Ethernet Controller driver: e1000e ver: 2.1.4-k port: bfe0 bus-ID: 01:00.0
               IF: eth0 state: down mac: 00:15:b7:42:be:5c
               Card-2: Intel PRO/Wireless 3945ABG [Golan] Network Connection driver: iwl3945 ver: in-tree:s bus-ID: 02:00.0
               IF: wlan0 state: up mac: 00:18:de:27:fb:dc
    Drives:    HDD Total Size: 80.0GB (20.7% used) 1: id: /dev/sda model: FUJITSU_MHV2080B size: 80.0GB temp: 38C 
    Partition: ID: / size: 73G used: 16G (23%) fs: ext4 ID: swap-1 size: 1.06GB used: 0.14GB (13%) fs: swap 
    RAID:      No RAID devices detected – /proc/mdstat and md_mod kernel raid module present
    Sensors:   System Temperatures: cpu: 51.0C mobo: N/A 
               Fan Speeds (in rpm): cpu: N/A 
    Info:      Processes: 174 Uptime: 48 min Memory: 507.9/994.4MB Runlevel: 2 Gcc sys: 4.7.3 Client: Shell inxi: 1.8.4
    When I ran xrandr -q, I got this:
    Screen 0: minimum 320 x 200, current 1280 x 800, maximum 32767 x 32767
    LVDS1 connected 1280×800+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
       1280×800       60.0*+
       1024×768       60.0  
       800×600        60.3     56.2  
       640×480        59.9  
    VGA1 disconnected (normal left inverted right x axis y axis)
    TV1 disconnected (normal left inverted right x axis y axis)
    I am still very new to this, so I don't know exactly what I am missing to get this setup.

    Any and all help is GREATLY appreciated!

  • mjhammel Post author

    The output from xrandr -q tells me that you’re display driver may not recognize that DVI port. You have an Intel graphics chipset. You might try using the latest Intel drivers which you can get from Intel Graphics for Linux website. To make sure you’ve got the right driver config, check which chipset you have using lspci. I don’t use LinuxMint so can’t say much about it other than it’s possible it may be a bit behind the curve when it comes to the latest Intel graphics drivers.