はじめに

LinuxのX11でデュアルヘッドディスプレイを設定したときの 設定内容と自作したスクリプトを備忘録として掲載しています。

マシン環境

私が使っているマシン環境は次のようになります。

X11の設定

Section "Extensions"
    Option "Composite"
EndSection
# **********************************************************************
# Refer to the xorg.conf man page for details about the format of
# this file.
# **********************************************************************

Section "ServerFlags"
    #DontZap # disable <Ctrl><Alt><BS> (server abort)
    AllowMouseOpenFail # allows the server to start up even if the mouse does not work
    #DontZoom # disable <Ctrl><Alt><KP_+>/<KP_-> (resolution switching)
EndSection

Section "Module"
    Load "dbe" # Double-Buffering Extension
    Load "v4l" # Video for Linux
    Load "extmod"
    Load "type1"
    Load "freetype"
    Load "glx" # 3D layer
    Load "dri" # direct rendering
EndSection

Section "InputDevice"
    Identifier "Keyboard1"
    Driver "kbd"
    Option "XkbModel" "jp106"
    Option "XkbLayout" "jp"
    Option "XkbOptions" "compose:rwin"
EndSection

Section "InputDevice"
    Identifier "Mouse1"
    Driver "mouse"
    Option "Protocol" "ExplorerPS/2"
    Option "Device" "/dev/mouse"
EndSection

Section "InputDevice"
    Identifier "SynapticsMouse1"
    Driver "synaptics"
    Option "SHMConfig" "on"
EndSection

Section "Monitor"
    Identifier "monitor1"
    VendorName "Plug'n Play"
    ModelName ""
    HorizSync 31.5-63
    VertRefresh 60-80

    # TV fullscreen mode or DVD fullscreen output.
    # 768x576 @ 79 Hz, 50 kHz hsync
    ModeLine "768x576"     50.00  768  832  846 1000   576  590  595  630

    # 768x576 @ 100 Hz, 61.6 kHz hsync
    ModeLine "768x576"     63.07  768  800  960 1024   576  578  590  616
EndSection

Section "Device"
    Identifier "device1"
    VendorName "Intel Corp."
    BoardName "Intel 810 and later"
    Driver "intel"
    Option "DPMS"
    Option "MonitorLayout" "NONE,CRT+LFP"
    Option "XaaNoOffscreenPixmaps" "1"
EndSection

Section "Screen"
    Identifier "screen1"
    Device "device1"
    Monitor "monitor1"
    DefaultColorDepth 24

    Subsection "Display"
        Depth 8
        Modes "1024x768" "832x624" "800x600" "640x480" "480x360" "320x240"
    EndSubsection

    Subsection "Display"
        Depth 15
        Modes "1024x768" "832x624" "800x600" "640x480" "480x360" "320x240"
    EndSubsection

    Subsection "Display"
        Depth 16
        Modes "1024x768" "832x624" "800x600" "640x480" "480x360" "320x240"
    EndSubsection

    Subsection "Display"
        Depth 24
        Modes "1024x768" "832x624" "800x600" "640x480" "480x360" "320x240"
        Virtual 2048 1024
    EndSubsection
EndSection

Section "ServerLayout"
    Identifier "layout1"
    InputDevice "Keyboard1" "CoreKeyboard"
    InputDevice "Mouse1" "CorePointer"
    InputDevice "SynapticsMouse1" "AlwaysCore"
    Screen "screen1"
EndSection

コントロールスクリプト

/usr/local/bin/DualHeadによりスクリプトで制御しています。

Example: Usageの表示:
[root@localhost ~]# /usr/local/bin/DualHead
Usage: DualHead [--auto|--on|--off|--split]
Example: ラップトップLCDと同じ表示で外部ディスプレイを有効にする:
[root@localhost ~]# /usr/local/bin/DualHead --on
Example: ラップトップLCDと外部ディスプレイとを仮想的に1つにする:
[root@localhost ~]# /usr/local/bin/DualHead --split
Example: /usr/local/bin/DualHeadの内容:
#!/bin/bash

case "$1" in
--auto)
        if xrandr -q | grep -q "VGA connected"; then
                EXTERNAL_MODE="--mode 1024x768"
        else
                EXTERNAL_MODE="--off"
        fi
;;
--on)
                EXTERNAL_MODE="--mode 1024x768"
;;
--off)
                EXTERNAL_MODE="--off"
;;
--split)
                EXTERNAL_MODE="--left-of LVDS "
;;
--help|*)
        echo "Usage: DualHead [--auto|--on|--off|--split] " >&2
        exit 0
;;
esac

xrandr --output LVDS --mode 1024x768 --output VGA  ${EXTERNAL_MODE}