4

I use my laptop with a second display. Sometimes I should take my laptop with me, but I can't take my second display with me. How can I setup my ubuntu 10.04 so that it changes the resolution automatically when I disable the second display?

My normal resolution (with the second display) is 2646*800. My resolution without the second display (laptop resolution) 1280*800.

What I want is:

  • When i disable second display, my resolution automatically (or by running some script) changes to 1280*800
  • When i connect second display resolution change to 2646*800.
1

2 Answers 2

2

You can use xrandr (assumming your driver supports it), for a nice guide check http://www.ubuntugeek.com/how-change-display-resolution-settings-using-xrandr.html .

1
  • That howto looks to only be for one monitor. If you have two, then it will be trying to set them both up all the time. Also, if the system is correctly detecting your resolution (xrandr outputs the correct resolution with a + next to it), you can use --preferred for it to pick the best option.
    – idbrii
    Jan 22, 2011 at 21:48
0

A simple way to use xrandr is with --preferred to use the detected settings.

Run xrandr to get the names of your outputs (I use LVDS1 and VGA1 below) and then you can use something like the following:

# enable both screens and put external left of laptop
xrandr --output LVDS1 --preferred --output VGA1 --left-of LVDS1 --primary --preferred

# enable laptop screen only
xrandr --output LVDS1 --preferred --output VGA1 --off

This is the script I use:

#! /bin/bash

# LVDS1 is my laptop monitor and VGA1 is my external monitor.
# These names can be found by running xrandr with no arguments.

# auto detect all connected monitors
xrandr --auto

if [ "$1" == "both" ] ; then
    # use best settings for both monitors
    xrandr --output LVDS1 --preferred --output VGA1 --above LVDS1 --primary --preferred
else
    # only use external monitor
    xrandr --output LVDS1 --off --output VGA1 --primary --preferred
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .