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.

5 Answers 5


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

  • Nice catch! Thank you for this hotkeys idea, i think I'll use it with my Archlinux-Ratpoison box.
    – dag729
    Oct 9, 2011 at 22:25
  • Do you know why this doesn't work when executing from the shell? When it's a script it works, however, when it's from the shell, I get unable to execute binary file.
    – cxdf
    Jul 29, 2013 at 16:44
  • @c-qjv0xfi I think it should work from both. Are you copying and pasting the whole line (including #!/bin/bash? You don't want that bit when in the shell. What happens if you just type xrandr and press enter? Oct 4, 2013 at 2:00
  • My latest Ubuntu Studio did not find disper by apt-get properly, so I tried your way. Perfect! I switched off my second screen and couldn't switch it on again. And I wanted to properly shutdown the OS, so I needed a way to switch back to one screen again. You can list the screen IDs by simply running xrandr. Then use those command up there. Dec 29, 2020 at 0:14

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.

  • Thank you for let me know Disper! Your solution doesn't fit for me just because I always have two monitors attached, but I want to toggle between display modes. Disper and you made my day!
    – dag729
    Sep 19, 2011 at 16:08
  • 1
    Well then just use disper -s to activate only the primary display, or disper -S to activate only the secondary display
    – jfoucher
    Sep 19, 2011 at 21:17
  • it does not seem to work on Ubuntu 18.04 LTS Dec 4, 2020 at 21:58

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
  • This is how I got disper to be installed, although I had to replace aptitude with apt-get.
    – Victor S
    Feb 21, 2012 at 15:07

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.

  • I don't get the benefit of toggle via "Display Preferences" over "NVidia Settings"... that's quite the same.
    – dag729
    Sep 19, 2011 at 13:48
  • @dag729 There isn't really a benefit, it's just that you have your question phrased in such a way that people without a NVidia card will try to google for it, find it and try to follow it. In addition, as far as I know, these instructions will work, as well as via NVidia Settings.
    – jrg
    Sep 19, 2011 at 14:26
  • On my setup this control panel does not properly detect the displays, only the Nvidia settings panel detect the displays properly. So I find this question useful in the particular answers it generated which do not involve this step here.
    – Victor S
    Feb 21, 2012 at 15:06

I find that sometimes when I unplug a screen my desktop icons, and therefore the Detect screens launcher I built according to @jfoucher suggestion isn't visible anymore. So that's useless. But to make life easier, you can add custom keyboard shortcuts that run commands, let me show you how!

enter image description here

enter image description here

You must log in to answer this question.

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