How can I toggle between single and dual monitor setup?

I have two monitors working just right with nvidia driver.

There are times, however, where I want to have just one monitor and other times where I need two: I must open NVidia XServer Settings, go to the XServer Display Configuration and change the second monitor from TwinView to Disabled (and vice-versa).

Is there a way to just toggle that? For example having a shortcut on desktop and/or on the Unity dock? Maybe is there a way to configure a keyboard shortcut to achieve this?

P.s.: I'm using 11.04 with Unity and, of course, Compiz.


Solution 1:

Have you tried using xrandr? I have three tiny executable scripts which I access with hotkeys. These switch between 1) laptop screen only, 2) monitor only 3) extended desktop across both. You might need to adjust them for your own uses.

#!/bin/bash xrandr --output LVDS1 --auto --output VGA1 --off

#!/bin/bash xrandr --output LVDS1 --off --output VGA1 --auto

#!/bin/bash xrandr --output VGA1 --primary --output LVDS1 --auto --left-of VGA1

Solution 2:

Install disper by clicking here or type sudo apt-get install disper in a terminal

Create a new launcher by right clicking on your desktop and selecting "Create Launcher..." Set the name to whatever you want, and the Command to disper -d auto -e

create launcher

Click Ok

Whenever you plug in or unplug your external monitor, just double click the launcher icon.

Solution 3:

To toggle display modes I used disper

sudo add-apt-repository ppa:disper-dev/ppa && sudo aptitude update && sudo aptitude install disper

then I added this python script, that is the indicator the better suits my needs, to my auto-run list.

To use that python script:

  1. download the script
  2. symlink it to /usr/bin (for instance if you have the script in /home/foo/disper_ind.py you have to write on terminal sudo ln -s /home/foo/disper_ind.py /usr/bin/disper_ind.py
  3. open "start-up applications", click "Add" and then put as command python /usr/bin/disper_indicator.py

Solution 4:

Open up display preferences:

enter image description here

Once you've got it open, click the monitor you want to turn off (in this example the 19"), and toggle the "On" switch to "Off". Then, hit apply. Your monitor of choice is turned off.

Then, you'll get a little dialog box that says "Hey, you've made some changes to your monitor setup. So, do you want to keep them?" - select "Yes" if you're happy with the new setup.

To revert it, just go in, select the monitor that's turned off and toggle it to "ON", then apply your changes and verify that everything looks ok.