Multiple monitor control from command line

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

Multiple monitor control from command line

Postby plantperson on 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.
plantperson
Level 1
Level 1
 
Posts: 20
Joined: Sat Oct 16, 2010 8:48 am

Linux Mint is funded by ads and donations.
 

Re: Multiple monitor control from command line

Postby Habitual on 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.
My DorkBlog
Cirrhus9.com - Managed HA VDSs and Scalable grid solutions.
User avatar
Habitual
Level 7
Level 7
 
Posts: 1924
Joined: Sun Nov 21, 2010 8:31 pm
Location: Under the hood

Re: Multiple monitor control from command line

Postby plantperson on 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.
plantperson
Level 1
Level 1
 
Posts: 20
Joined: Sat Oct 16, 2010 8:48 am

Re: Multiple monitor control from command line

Postby kwevej on 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
User avatar
kwevej
Level 5
Level 5
 
Posts: 624
Joined: Mon Mar 22, 2010 3:35 pm
Location: Delft / Prague [@ LMDE]


Return to Newbie Questions

Who is online

Users browsing this forum: No registered users and 3 guests