Page 1 of 1

Multiple monitor control from command line

Posted: Sun Mar 06, 2011 12:49 pm
by plantperson
Hello all,
I've had great success connecting my external monitor to my netbook so that I can use a full-size display, but the setup is currently somewhat inconvenient in its current form. I often have to switch back to the built-in display to take the computer elsewhere, and to do that requires going into the gnome monitor panel and reconfiguring everything. What I'd like would be a series of commands I could use to switch the configuration from one monitor to the other. Even better would be a script which would automatically switch to the big display when it's connected, and vice-versa. Any suggestions?

Just to be clear, I'm not using a multiple-monitor setup here... I only use one at a time.

Re: Multiple monitor control from command line

Posted: Sun Mar 06, 2011 2:20 pm
by Habitual

Code: Select all

xrandr --output LVDS1 --auto
turns my Lappy Screen on and

Code: Select all

xrandr --output LVDS1 --off
turns it off

Hope that helps.

As for the scripting of connected vs not connected, I'm sure one of our talented gurus probably can come up with something.

Re: Multiple monitor control from command line

Posted: Sun Mar 06, 2011 3:06 pm
by plantperson
Thanks! This has allowed me to create the following little script:

Code: Select all

#!/bin/bash
echo "MAIN SCREEN TURN ON. Please choose (l)aptop or (m)ain:"

read CHOICE
	
	case $CHOICE in
		l)xrandr --output LVDS1 --auto
		  xrandr --output VGA1 --off
		  echo "For Great Justice.";;
		
		m)xrandr --output VGA1 --auto
		  xrandr --output LVDS1 --off
		  echo "For Great Justice.";;
		
		*)echo "Somebody set up us the bomb.";;
	esac
It doesn't work on its own, but it's still much faster than doing it through the gnome panels.

Re: Multiple monitor control from command line

Posted: Thu Mar 10, 2011 3:18 am
by kwevej
This might be useful for you as well - you can set your primary monitor, and positioning as well
That's what I use:

setup monitors

Code: Select all

xrandr --output LVDS1 --primary
xrandr --output VGA1 --auto --pos 0x0 --output LVDS1 --auto --below VGA1
unset

Code: Select all

xrandr --output VGA1 --off --output LVDS1 --auto