different resolutions in virtual desktop

Duncan 1i5t5.duncan at cox.net
Tue Apr 27 21:09:29 BST 2010


mierdatutis mi posted on Tue, 27 Apr 2010 16:32:25 +0200 as excerpted:

> Well, my "problem" is that I have two monitors in clone mode. I have the
> tv signal and the lc monitor connected to my ATI graphic card, because
> with this way, I change my tv channel I can see the pc to can use XBMC.
> The problem is that I have a resolution of 1440x900 60hz in my monitor
> lcd (native resolution of my monitor LCD), and when I see in the tv is
> too small and I cant see very well the letters. My main idea was that in
> a virtual desktop have a 1440x900 resolution and in other virtual
> desktop 1024x780 but now I know that is impossible. Do you help me to
> can change the resolution from a bash script?
> 
> Many thanks and sorry for my english!

Your English is actually better than many native speakers speak (write) 
it!  That's one reason I didn't spot what Tassilo Horn (referred to below 
as TH) has now mentioned, that your use of the term "virtual desktops" 
wasn't quite what I was thinking.  The other was the lack of any real 
details of what you were trying to do.

TH mentions the problem with differing resolutions in clone mode, that the 
lower resolution one then shows only a part of what the larger one shows, 
but xrandr is flexible enough to work around it using panning, if you 
wish.  Of course, panning has its own issues, the biggest one being that 
it takes some getting used to, and it makes many folks a bit dizzy and 
disoriented until they do.  Some folks never adapt, but used in a limited 
fashion, I find it useful, tho I'd not like to use it all the time as my 
main work mode.

TH has reasonably basic script that looks like it should work fine in 
bash.  It demonstrates the basic ideas, tho as he points out, doesn't 
quite do what you wish, clone mode.

My script is a bit more complex, using a few more of the xrandr features, 
but still doesn't do exactly what you want, and I've not abstracted it to 
the point of general use yet, tho it should be reasonably clear what needs 
changing.

You'll also want to refer to the xrandr manpage.  Hopefully, it's 
installed on whatever distribution you run.  You can load it with "man 
xrandr", run in konsole.  That gives you an overview of the command and 
its command line options, explaining what each one does.

I also have an ATI card, now a Radeon hd4650, tho I used the same script, 
with a couple slight changes (basically, the new card has two DVI outputs, 
DVI-0 and DVI-1, the old one had VGA-0 and DVI-0, so I had to change that 
in the script, you'll probably need similar changes, among others), on my 
old Radeon 9200.  So the script should work well across all of them.

The other detail to consider is that I'm running the xorg native xf86-
video-ati driver, configured in xorg.conf to use radeon.  If you're using 
the proprietary frglx, things may or may not work the same.  You'll also 
want a reasonably new xorg and driver.  RandR panning was only added in 
randr 1.3, IIRC, so for the xf86-video-ati 6.12 series (I'm running 
6.13.0, now).  You'll want xrandr 1.3 series and a reasonably new xorg-
server as well, tho I don't know what's required there.  (I'm running 1.8 
but 1.7 worked, IDR whether 1.6 and 1.5 did, or not.)  That's of course 
assuming you want panning.  If you can do without panning, xrandr 1.2 and 
older versions of the other xorg related components may be fine, tho there 
was a bug in I believe the older xf86-video-ati drivers, that caused 
xrandr not to work as documented in terms of the --pos option, which I 
didn't need any more once panning worked, since I could just pan to where 
I wanted to be.

Looking at the xrandr manpage, you might be interested in the --scale 
option.  I've never used it here, as it wasn't what I needed, but it may 
well fix your problem without bothering with some of the other options 
that I use.

Now explaining my script:

My setup is two LCD monitors, same brand and model, so identical size (24 
inch diagonal, 518x324 mm, according to the xorg log) and native 
resolution -- 1920x1200.  Like TH, I create a bigger total desktop with 
them, not cloned.  Unlike TH, I stack mine, doubling the vertical 
resolution for 1920x2400 total resolution at native.  The script assumes a 
top/bottom orientation in its variable names, etc, but I've begun the 
process of abstracting the values into variables and from there into a 
config file, so it shouldn't be too difficult to change them, as 
necessary.  As the comment in the script suggests, you'd make the changes 
in three places, the variable values at the top, the help text, and the 
case statement.

You'll find the actual script copied in just below my sig.  It's designed 
so it can be run from a konsole session for debugging purposes, thus the 
xrandr --verbose option.

Once you get a script setup and working when invoked manually, if you 
wish, we can talk about invoking it with a hotkey and/or adding it to the 
applications menu, then.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman

#!/bin/bash
# xrandr helper script
# command line parameter setup
Size=${1:-0}		# requested size factor or help trigger, default 
is "0"
################################################################################
################################################################################
# Variables listed in this double-line demarked section are *.conf 
candidates
# as they change with the graphics layout.  But script isn't ready for that
# yet as the case statement and help function need abstracted to variables 
first.
# (IOW, change them too as necessary.)

# total framebuffer size
FBuf=1920x2400

################################################################################
# monitor top/bottom settings
#names (xrandr names)
MonTopName=DVI-0
MonBotName=DVI-1

# panning
# pan-area XxY, pan-offset X+Y
MonTopPanArea=1920x1200
MonBotPanArea=$MonTopPanArea
MonTopPanOffs=0+0
MonBotPanOffs=0+1200
# track-area XxY track-offset X+Y
MonTopTrkArea=$MonTopPanArea
MonBotTrkArea=$MonTopTrkArea
MonTopTrkOffs=$MonTopPanOffs
MonBotTrkOffs=$MonBotPanOffs
# borders, left/top/right/bottom
MonTopBrd=20/20/20/20
MonBotBrd=$MonTopBrd
# mode (cleared here, set below)
MonTopMode=
MonBotMode=
################################################################################
################################################################################
# These variables in ALLCAPS are xrandr literals and thus shouldn't need 
changed
# all are xrandr 1.2 except panning, xrandr 1.3
FBUF=--fb
MODE=--mode
OPUT=--output
PAN=--panning
VERB=--verbose

################################################################################
helptxt() {
	echo
	echo Usage: "${0##*/} [-h|--help|<size>]"
	echo
	echo "Sets X dual-display size within a framebuffer of $FBuf."
	echo "Unless otherwise stated, monitor orientation is stacked, 
modes duplicated."
	echo
	echo "Where <size>is one of (first column)..."
	echo
	echo "    size and   resolut'n res       notes"
	echo "    aliases    each      total"
	echo
	echo "dup modes with x/y ratio 1.6 each, 0.8 total"
	echo "    19|1920|0  1920x1200 1920x2400 (default)"
	echo "    16|1680    1680x1050 1650x2100 "
	echo "    14|1440    1440x900  1440x1800 "
	echo "    12|1280    1280x800  1280x1600 "
	echo "    11|1120    1120x700  1120x1400 "
	echo "     9|960      960x600   960x1200 "
	echo "     8|840      840x525   840x1050 "

#	echo "     7|720      720x450   720x900  1/8"
#	echo "     6|640      640x400   640x800  1/7"
#	echo "     5|560      560x350   560x700  1/6"
#	echo "     4|480      480x300   480x600  1/6.5"
#	echo "     4|416      416x260   416x520 ~1/7"
#	echo "     3|360      360x225   360x450  1/8"
#	echo "     3|320      320x200   320x400  "

	echo "dup modes with ratio 1.33 each, 0.67 total"
	echo "   10x|1024x   1024x768  1024x1536 "
	echo "    8x|800x     800x600   800x1200 "
	echo "    6x|640x     640x480   640x960  "
	echo
	echo "non-dup modes  res-top  ratio res-bot ratio notes"
	echo "19-6|1920-640  1920x1200 1.6  640x480 1.33  Run old 640x480 
games full bottom monitor"
	echo "19-9|1920-960  1920x1200 1.6  960x600 1.6   Run 320x200 
games 3x, full bottom monitor"
	echo
	exit
}

################################################################################
################################################################################
# ModBotMode defaults to ModTopMode, below, other defaults set above.
case $Size in
# ratio x/y 1.6 each, 0.8 total
	19|1920|0)	MonTopMode=1920x1200;; # default
	16|1680)	MonTopMode=1680x1050;;
	14|1440)	MonTopMode=1440x900;;
	12|1280)	MonTopMode=1280x800;;

	11|1120)	MonTopMode=1120x700;;
	9|960)		MonTopMode=960x600;;
	8|840)		MonTopMode=840x525;;

#	7|720)		MonTopMode=720x450;;
#	6|640)		MonTopMode=640x400;;
#	5|560)		MonTopMode=560x350;;
#	4|480)		MonTopMode=480x300;;

# ratio 1.33 each, 0.67 total
	10x|1024x)	MonTopMode=1024x768;;
	8x|800x)	MonTopMode=800x600;;
	6x|640x)	MonTopMode=640x480;;

# special cases
# top/bottom resolution not duped, DOSBOX/Master of Orion in bottom, 
MonBot borders zeroed
	19-6|1920-640)	MonTopMode=1920x1200 MonBotMode=640x480 
MonBotBrd=;;
	19-9|1920-960)	MonTopMode=1920x1200 MonBotMode=960x600 
MonBotBrd=;;
# catch-all help entry
	*)		helptxt;;
esac

################################################################################
# If not specifically set above, MonBotMode defaults to MonTopMode
[ $MonBotMode ] || MonBotMode=$MonTopMode

# Do some pre-command var concatenation here
FBuf="$FBUF $FBuf"
MonTopName="$OPUT $MonTopName"
MonBotName="$OPUT $MonBotName"
MonTopMode="$MODE $MonTopMode"
MonBotMode="$MODE $MonBotMode"
MonTopPan="$PAN $MonTopPanArea+$MonTopPanOffs/$MonTopTrkArea+
$MonTopTrkOffs/$MonTopBrd"
MonBotPan="$PAN $MonBotPanArea+$MonBotPanOffs/$MonBotTrkArea+
$MonBotTrkOffs/$MonBotBrd"

################################################################################
# DO IT!!
set -x
xrandr $VERB $FBuf	$MonTopName $MonTopMode $MonTopPan \
			$MonBotName $MonBotMode $MonBotPan


___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.




More information about the kde mailing list