dual head with xrandr

Thursday, May 31st, 2007 | Free Software, geek

I use a laptop with the 915GM chipset. This means that I can use xrandr (yes!!!!). During login I (automatically) run the following little script that checks if I have plugged in the external monitor and if so splits the screen. If I later on unplug the monitor I simply run the script again and same goes for replugging it.

#!/bin/sh

VGA_USED=$(xrandr | grep -c “VGA connected” )
LVDS_USED=$(xrandr | grep -c “LVDS connected” )

setup_dual_head()
{
xrandr –output LVDS –auto –pos 0×0 –left-of VGA
}

setup_mono_head()
{
xrandr –output LVDS –auto
}

if [ “$VGA_USED” == “1″ ]
then
setup_dual_head
else
setup_mono_head
fi

To make this work make sure you have setup X correctly. In the screen section I have the following important part (note the virtual size):

SubSection “Display”
Viewport 0 0
Modes “1280×1024″
Virtual 2560 1824
Depth 24
EndSubSection

No comments yet.

Leave a comment

You must be logged in to post a comment.

Search