Omnigia

September 30, 2008

X, with and without an external monitor

Filed under: linux — Dan Muresan @ 5:17 pm

As a laptop user, I often find myself switching between LCD-only, external-monitor-only, and dual-screen setups. Read below for a summary of how to achieve this flexibility under X (more specifically Xorg), both statically (via multiple configuaration files, requiring X restarts) and dynamically (while X is running) — but also some of the gotchas you will run into.

  1. Some static configurations
    You can have multiple xorg.conf configuration files, but they all must reside in /etc. To start Xorg with a specific configuration file, use, for example:

    startx -- -config xorg.conf.external

    If you’ve already started X, you can also start a distinct X session by specifying a new display number:

    startx -- :1 -config xorg.conf.external
    • A configuration that disables the laptop screen: in the Device section of xorg.conf.*, add

              Option "monitor-LVDS" "LVDS"
      

      Also add a Monitor section:

      Section "Monitor"
              Identifier "LVDS"
              Option "Ignore" "True"
      EndSection
    • The same effect can be achieved using TwinView for NVIDIA cards:
      Section "Screen"
          Option         "TwinView" "True"
          Option         "MetaModes" "nvidia-auto-select, off"
      EndSection
      
    • To enable both screens, you can use a vanilla xorg.conf (as generated for example by sudo Xorg -configure); xrandr can then configure dual-head, as described in the next section. However, I have noticed that under this setup X disables the XVideo support (meaning, for example, a slower mplayer); I don’t know if there’s a way to avoid this problem.
  2. Dynamic configuration
    #disable laptop screen
    xrandr --output LVDS --off
    # switch back to laptop screen
    xrandr --output VGA --off
    xrandr --output LVDS --auto
    # dual-head (laptop + external)
    xrandr --output VGA --above LVDS
    # --left-of, --below etc. also work

    For the last xrandr command (dual-head), your combined external + laptop virtual screen resolution must not exceed the virtual desktop size. If not specified in xorg.conf, the X server pre-computes it at startup as the highest resolution of all monitors connected to your computer (i.e. if you start with your external monitor disconnected, the laptop’s resolution; if the external monitor is connected at start-up, it will most likely dictate the virtual). Therefore you will most likely want to specify the virtual desktop size:

    Section Screen
      Subsection Display
        Depth 32
        Virtual 2048 2048
      EndSubsection
    EndSection

    However, as a further twist, some cards lose graphics acceleration capabilities when the virtual size is too high. If you notice your browser scrolling a page slower than normal, for example, this may be to blame.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

[ Powered by WordPress ]