trinity-users@lists.pearsoncomputing.net

Message: previous - next
Month: December 2016

Re: Re: Dual screen setup not remembered

From: deloptes <deloptes@...>
Date: Thu, 01 Dec 2016 21:00:01 +0100
iadest@... wrote:

> OK, this is a sum of 3 scripts I use:
> 
> #!/bin/bash
> 
> #Test if we are not in dock
> if [ -a /dev/video0 ]
> then
> #echo "Going to dock mode!";
> xrandr --output LVDS1 --off
> #xrandr --output VGA1 --mode 1600x1200
> xrandr --newmode "1600x1200b" 180.0   1600 1604 1796 2050 1200
> 1201 1204 1250 +hsync +vsync
> xrandr --addmode VGA1 1600x1200b
> xrandr --output VGA1 --primary --mode 1600x1200b
> xrandr --addmode DVI1 1600x1200b
> xrandr --output DVI1 --mode 1600x1200b
> xrandr --output DVI1 --right-of VGA1
> else
> #we are not in dock. Check do we have output on VGA
> 
> if [ -n "`xrandr | grep \"VGA1 conected\"`" ]
> then
> #echo "Going to projector mode!";
> xrandr --output LVDS1 --mode 1024x768 --output VGA1
> --mode 1024x768 --same-as LVDS1
> fi
> fi
> 
> There may be problems with newlines. "1201 1204 ..." is the continuing
> of previous line. "--mode 1024x768 --same-as LVDS1" is also in previous
> one.
> 
> WARNING: Do not use this script directly on Your monitor without
> checking. High frequency may damage the monitor, especially old CRTs.
> 
> So what I'm doing there: first I check for availability of my tuner
> card, this card is installed in dock. It computer is in dock, I:
> 1. Turn the LCD off
> 2. Set a custom 1600x1200 mode (here called "1600x1200b" for my
> monitor which is connected through Sun-VGA adapter and X has no idea
> how to handle 1600x1200 on it.
> 3. Activate it as primary.
> 4. Activate the second display (DVI) as the one right of VGA monitor.
> If I'm not in dock, I look for something connected to VGA port.
> If there is, LCD gets down to 1024x768, and VGA copies it.
> 
> MCbx
> 
> Gerhard Zintel <gerhard.zintel@...>
> napisaƂ(a):
> 
>> On Thursday 01 December 2016, deloptes wrote:
>> > iadest@... wrote:
>> > 
>> > > Maybe this solution is not official and proper one, but works:
>> > > Put the xrandr commands in a shell script and execute is at
>> > > startup.
>> > > 
>> > > I have such script which detects is my notebook docked first. If
>> > > yes, dual-screen configuration for dock outputs are set and
>> > > notebook's LCD is turned off.
>> > > If it's not docked, script checks for display connected to VGA
>> > > port. If it is, it duplicates screen from notebook decreasing
>> > > resolutions to 1024x768 as it's usually a projector in a lecture
>> > > room and it can't do more.
>> > > MCbx
>> > 
>> > I do the same. In the office I have two additional monitors and at
>> > home one. So a shell script is checking what is available and runs
>> > xrandr to setup the monitor and resolution.
>> > Perhaps this is the reason we never noticed that the settings are
>> > not saved and/or applied at tde session startup.
>> > In fact I have noticed this on a VM ware recently, but I was
>> > thinking it has to do with the vmware.
>> > I think it is worth a bug report, so that we may not forget to
>> > inspect this.
>> 
>> Can one of you guys please share that kind of shell script here on
>> the list to give me a clue how to start?
>> 
>> Gerhard
>> 

SCREEN=`xrandr | egrep "[[:space:]]connected[[:space:]]" | grep -v eDP1`
if [[ "x"$SCREEN != "x"  ]]
then
        xrandr --output $SCREEN --right-of eDP1 --auto
        xrandr --output eDP1 --off
else
        xrandr --output eDP1 --auto
fi

eDP1 or LVDS depends on your card - look into the driver manual