Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.
share|improve this question
Looks like someone wrote the script you're looking for. See this question:… – idbrii Jan 22 '11 at 21:50

You can use xrandr (assumming your driver supports it), for a nice guide check .

share|improve this answer
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 '11 at 21:48

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
    # only use external monitor
    xrandr --output LVDS1 --off --output VGA1 --primary --preferred
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.