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.

Using Ubuntu 10.10. I have an external screen and frequently move my computer in and out of the room.

Is there a way of avoiding manually configuring via nvidia-settings every time I need to take my laptop out of my room?

Would like to be able to press Ctrl + 1 and have only the laptop screen active, Ctrl + 2 for the external only, and Ctrl + 3 for TwinView.

share|improve this question

2 Answers 2

My answer may not 100% appropriate for your case as I use ATI drivers, but I use a little script that would detect an external monitor and in that case enable it, using xrandr command line tool. Then I created a key shortcut that runs it.

If xrandr also runs on your config you could use a modified version of it. xrandr is contained in package "x11-xserver-utils", so you first may need to run "sudo apt-get install x11-xserver-utils" in console.

What you need to modify in the script:

  • First run "xrandr -q" in console to find out what name your main and external monitor have. Mine are "LVDS" and "DisplayPort-0".
  • Set EXT_DISPLAY in the script to the name of your external monitor
  • Set MAIN_DISPLAY in the script to the name of your main monitor
  • Leave EXT_POS to "right" to have the external monitor to the right of your main monitor, replace it with "left" (or actually anything else) to have it to the left

The script:

#!/bin/bash

EXT_DISPLAY="DisplayPort-0"
MAIN_DISPLAY="LVDS"
EXT_POS="right"

EXT_OUTPUT="NONE"
xrandr -q > /var/tmp/xrandr.log

STATUS_DISPLAYPORT=$(xrandr -q | sed -n "s/${EXT_DISPLAY} \([a-z]*\).*/\1/p")

if [ "$STATUS_DISPLAYPORT" = "connected" ]; then
    echo "Detected external monitor on $EXT_DISPLAY"
    EXT_OUTPUT="$EXT_DISPLAY"
fi

if [ "$EXT_OUTPUT" = "NONE" ]; then
    echo "LCD only"

else
    echo "Enabling external monitor $EXT_OUTPUT"
    if [ "$EXT_POS" = "right" ]; then
        xrandr --output $MAIN_DISPLAY --pos 0x0 --preferred --output $EXT_OUTPUT --right-of $MAIN_DISPLAY --preferred
    else
        xrandr --output $EXT_OUTPUT --pos 0x0 --preferred --output $MAIN_DISPLAY --right-of $EXT_OUTPUT --preferred 
    fi
fi

Store the script in some dir, give it execution rights and define a keyboard shortcut that starts it. Works well at least here.

share|improve this answer

I use disper: https://launchpad.net/~disper-dev/+archive/ppa. you can assign the command disper -s to a shortcut for only your primary display, disper -S for only your secondary monitor, disper -e for a extended desktop, and disper -c for a clone on both displays. I had to tweek it a bit to set my primary monitor right for the extended desktop I use the command disper -d CRT-1,DFP-0 -e, where CRT-1 and DFP-0 are the names of the monitors found with disper -l.

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.