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 have a Ubuntu machine next to my TV. Sometimes I use my TV (hdmi) as a secondary monitor, twinview.

Using the "NVidia X Server Setting", nvidia-settings, I can turn the second monitor (TV) on or off. (NVidia driver version is 260.19.06)

However, since I do this quite frequently I would like to install a keyboard shortcut. So step one is to turn on/off the 2nd monitor using command line.

Any idea on how to control this, using command line?

Cheers Leif

share|improve this question
up vote 8 down vote accepted

disper has worked very well for me for controlling an nVidia card for the same purpose. My second display was a TV, btw. You can install disper from this ppa:

share|improve this answer
This program allows me to switch to a second monitor without restarting xserver! This is what I was looking for! My dream came true! ;) Many thanks for this! – lukasz Oct 27 '10 at 11:02
Works like a charm! Thanks. – leiflundgren Oct 29 '10 at 22:27
From an anonymous user: since nvidia 302 disper does not work any more // before this upgrade it worked very well for me – hexafraction Sep 7 '12 at 0:05

try nvidia-settings -h

I'm not sure about this, but nvidia-settings seams to be a graphical front-end to edit ~/.nvidia-settings-rc

So if you save this file, use nvidia-settings, to add the TV display and save your settings, you should have two configuration files for your two setups.

Now use nvidia-settings -l conffile to change the configuration.

A bashscript could look like:

mv conf1 tmp.conf1
mv conf2 conf1
mv tmp.conf1 conf2
nvidia-settings -l conf1

So this would toggle between the two settings

share|improve this answer
Sounds prommising, but. Tried. nvidia-settings -V --load-config-only --config=.nvidia-settings-rc-onemonitor-only And nothing happendedn. I would have suspected screens blinking and shuting down. Can you spot an obvious error on my part? Regards – leiflundgren Oct 27 '10 at 20:27
I just tried it, it does not seam to work :( If you check nvidia-settings -q you see that most attributes are read only, and the values you need are not saved in .nvidia-settings-rc, so until somebody comes up with a way to correctly handle nvidia-settings my answer is useless – sBlatt Oct 28 '10 at 8:50

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.