Multiple monitor control from command line

Archived topics about LMDE 1 and LMDE 2
Locked
plantperson

Multiple monitor control from command line

Post 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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Habitual

Re: Multiple monitor control from command line

Post 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.
plantperson

Re: Multiple monitor control from command line

Post 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.
kwevej

Re: Multiple monitor control from command line

Post 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
Locked

Return to “LMDE Archive”