Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

5 Answers 5

up vote 5 down vote accepted

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.

share|improve this answer
    
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 '11 at 16:08
    
Well then just use disper -s to activate only the primary display, or disper -S to activate only the secondary display –  jfoucher Sep 19 '11 at 21:17

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

share|improve this answer
    
Nice catch! Thank you for this hotkeys idea, i think I'll use it with my Archlinux-Ratpoison box. –  dag729 Oct 9 '11 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. –  c-qjv0xfi Jul 29 '13 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? –  oldmankit Oct 4 '13 at 2:00

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
share|improve this answer
    
This is how I got disper to be installed, although I had to replace aptitude with apt-get. –  Victor S Feb 21 '12 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.

share|improve this answer
    
I don't get the benefit of toggle via "Display Preferences" over "NVidia Settings"... that's quite the same. –  dag729 Sep 19 '11 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 '11 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 '12 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

share|improve this answer

Your Answer

 
discard

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.