Multiple monitor control from command line

Archived topics about LMDE 1
Forum rules
plantperson
Level 1
Level 1
Posts: 21
Joined: Sat Oct 16, 2010 8:48 am

Multiple monitor control from command line

Postby plantperson » Sun Mar 06, 2011 12:49 pm

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.

User avatar
Habitual
Level 12
Level 12
Posts: 4096
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: Multiple monitor control from command line

Postby Habitual » Sun Mar 06, 2011 2:20 pm

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.
Windows assumes you're an idiot.
Linux demands proof of it.

plantperson
Level 1
Level 1
Posts: 21
Joined: Sat Oct 16, 2010 8:48 am

Re: Multiple monitor control from command line

Postby plantperson » Sun Mar 06, 2011 3:06 pm

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.

User avatar
kwevej
Level 5
Level 5
Posts: 582
Joined: Mon Mar 22, 2010 3:35 pm
Location: Delft / Prague [@ LMDE]

Re: Multiple monitor control from command line

Postby kwevej » Thu Mar 10, 2011 3:18 am

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


Return to “Archive”

Who is online

Users browsing this forum: No registered users and 8 guests