https://wiki.archlinux.org/api.php?action=feedcontributions&user=Bantuvez&feedformat=atomArchWiki - User contributions [en]2024-03-28T14:21:35ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Xrandr&diff=203165Xrandr2012-05-29T08:17:17Z<p>Bantuvez: quotation marks are not needed there</p>
<hr />
<div>[[Category:X Server]]<br />
{{i18n|Xrandr}}<br />
<br />
== Dynamically testing different resolutions ==<br />
<br />
{{Ic|xrandr}} shows you the names of different outputs available on your system (LVDS, VGA-0, etc.) and resolutions available on each:<br />
<br />
Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 1400 x 1400<br />
VGA disconnected (normal left inverted right x axis y axis)<br />
LVDS connected 1400x1050+0+0 (normal left inverted right x axis y axis) 286mm x 214mm<br />
1400x1050 60.0*+ 50.0 <br />
[...]<br />
<br />
You can direct xrandr to set a different resolution like this:<br />
<br />
xrandr --output LVDS --mode 1024x768<br />
<br />
The refresh rate may also be changed, either at the same time or independently:<br />
<br />
xrandr --output LVDS --mode 1024x768 --rate 75<br />
<br />
Note that changes you make using {{Ic|xrandr}} only last through the current session. xrandr has a lot more capabilities - see {{Ic|man xrandr}} for details.<br />
<br />
== Adding undetected resolutions ==<br />
<br />
Due to buggy hardware or drivers, your monitor's correct resolutions may not always be detected by xrandr. For example, the EDID data block queried from the monitor may be incorrect. However, we can add the desired resolutions to xrandr.<br />
<br />
First we run {{ic|gtf}} or {{ic|cvt}} to get the '''Modeline''' for the resolution we want:<br />
<br />
$ cvt 1280 1024<br />
<br />
# 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz<br />
Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync<br />
<br />
Then we create a new xrandr mode. Note that the Modeline keyword needs to be ommited.<br />
<br />
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync<br />
<br />
After creating it we need an extra step to add this new mode to our current output (VGA1). We use just the name of the mode, since the parameters have been set previously.<br />
<br />
xrandr --addmode VGA1 1280x1024_60.00<br />
<br />
Now we change the resolution of the screen to the one we just added:<br />
<br />
xrandr --output VGA1 --mode 1280x1024_60.00<br />
<br />
Note that these settings only take effect during this session.<br />
<br />
== Making xrandr changes persistent ==<br />
<br />
There are several ways to make xrandr customizations permanent from session to session:<br />
* {{ic|xorg.conf}} ( Preferred)<br />
* {{ic|.xprofile}}<br />
* kdm/gdm<br />
<br />
=== Setting resolution changes in xorg.conf (Preferred) ===<br />
<br />
While {{Ic|xorg.conf}} is largely empty these days, it can still be used for setting up resolutions. For example:<br />
<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "Monitor"<br />
Identifier "External DVI"<br />
Modeline "1280x1024_60.00" 108.88 1280 1360 1496 1712 1024 1025 1028 1060 -HSync +Vsync<br />
Option "PreferredMode" "1280x1024_60.00"<br />
EndSection<br />
Section "Device"<br />
Identifier "ATI Technologies, Inc. M22 [Radeon Mobility M300]"<br />
Driver "ati"<br />
Option "Monitor-DVI-0" "External DVI"<br />
EndSection<br />
Section "Screen"<br />
Identifier "Primary Screen"<br />
Device "ATI Technologies, Inc. M22 [Radeon Mobility M300]"<br />
DefaultDepth 24<br />
SubSection "Display"<br />
Depth 24<br />
Modes "1280x1024" "1024x768" "640x480"<br />
EndSubSection<br />
EndSection<br />
<br />
Section "ServerLayout"<br />
Identifier "Default Layout"<br />
Screen "Primary Screen"<br />
EndSection<br />
}}<br />
<br />
See {{Ic|man xorg.conf}} for full details on how to craft an {{ic|xorg.conf}} file.<br />
<br />
=== Setting xrandr commands in xprofile ===<br />
<br />
See [[Execute commands after X start]].<br />
<br />
This method has the disadvantage of occurring fairly late in the startup process thus it will not alter the resolution of the [[Display Manager]] if you use one.<br />
<br />
=== Setting xrandr commands in kdm/gdm startup scripts ===<br />
<br />
Both KDM and GDM have startup scripts that are executed when X is initiated. For GDM, these are in {{ic|/etc/gdm/}} , while for KDM this is done at {{ic|/usr/share/config/kdm/Xsetup}}.<br />
<br />
This process requires root access and mucking around in system config files, but will take effect earlier in the startup process than using xprofile.<br />
<br />
== Graphical frontends ==<br />
There are some graphical frontends available for {{ic|xrandr}}:<br />
<br />
=== ARandR ===<br />
ARandR provides a simple and convenient visual front end.<br />
<br />
The package can be found in the community repository: {{Pkg|arandr}}<br />
<br />
=== LXrandR ===<br />
The default monitor configuration tool for the [[LXDE]] desktop environment. <br />
<br />
This package is part of the community repository: {{Pkg|lxrandr}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Resolution lower than expected ===<br />
<br />
==== Try this first ====<br />
<br />
If you video card is recognized but the resolution is lower than you expect, you may try this.<br />
<br />
Background: ATI X1550 based video card and two LCD monitors DELL 2408(up to 1920x1200) and Samsung 206BW(up to 1680x1050). Upon first login after installation, the resolution default to 1152x864. xrandr does not list any resolution higher than 1152x864. You may want to try editing /etc/X11/xorg.conf, add a section about virtual screen, logout, login and see if this helps. If not then read on.<br />
<br />
Change xorg.conf<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "Screen"<br />
...<br />
SubSection "Display"<br />
Virtual 3600 1200<br />
EndSubSection<br />
EndSection<br />
}}<br />
<br />
About the numbers: DELL on the left and Samsung on the right. So the virtual width is of sum of both LCD width 3600=1920+1680; Height then is figured as the max of them, which is max(1200,1050)=1200. If you put one LCD above the other, use this calculation instead: (max(width1, width2), height1+height2).<br />
<br />
==== Use cvt/xrandr tool to add the highest mode the LCD can do ====<br />
<br />
The actual order was different, as I tried to add new mode to one LCD at a time. Below is the combined/all-in-one quote<br />
$ cvt 1920 1200 60<br />
# 1920x1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz<br />
Modeline "1920x1200_60.00" 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync<br />
$ cvt 1680 1050 60<br />
# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz<br />
Modeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync<br />
$ xrandr --newmode "1920x1200_60.00" 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync<br />
$ xrandr --newmode "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync<br />
$ xrandr --addmode DVI-1 "1920x1200_60.00"<br />
$ xrandr --addmode DVI-0 "1680x1050_60.00"<br />
<br />
== Obtaining modelines from Windows program PowerStrip ==<br />
<br />
[http://www.x.org/wiki/FAQVideoModes#ObtainingmodelinesfromWindowsprogramPowerStrip Obtaining modelines from Windows program PowerStrip].<br />
<br />
== Scripts ==<br />
<br />
Toggle only secondary monitor, leave the default display on:<br />
{{hc|~/bin/xdisplay|2=<nowiki><br />
#!/bin/bash<br />
#<br />
# This script toggles the extended monitor outputs if something is connected<br />
#<br />
<br />
# your notebook monitor<br />
DEFAULT_OUTPUT='LVDS1'<br />
<br />
# outputs to toggle if connected<br />
OUTPUTS='VGA1 HDMI1'<br />
<br />
# get info from xrandr<br />
XRANDR=`xrandr`<br />
<br />
EXECUTE=""<br />
<br />
for CURRENT in $OUTPUTS<br />
do<br />
if [[ $XRANDR == *$CURRENT\ connected* ]] # is connected<br />
then<br />
if [[ $XRANDR == *$CURRENT\ connected\ \(* ]] # is disabled<br />
then<br />
EXECUTE+="--output $CURRENT --auto --above $DEFAULT_OUTPUT "<br />
else<br />
EXECUTE+="--output $CURRENT --off "<br />
fi<br />
else # make sure disconnected outputs are off <br />
EXECUTE+="--output $CURRENT --off "<br />
fi<br />
done<br />
<br />
xrandr --output $DEFAULT_OUTPUT --auto $EXECUTE<br />
</nowiki>}}<br />
<br />
Switches display, turning the others off:<br />
<br />
{{hc|/usr/local/bin/toggle-display|2=<nowiki><br />
#!/bin/bash<br />
#<br />
# toggle-display.sh<br />
#<br />
# Iterates through connected monitors in xrander and switched to the next one<br />
# each time it is run.<br />
#<br />
<br />
# get info from xrandr<br />
xStatus=`xrandr`<br />
connectedOutputs=$(echo "$xStatus" | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")<br />
activeOutput=$(echo "$xStatus" | grep -e " connected [^(]" | sed "s/\([A-Z0-9]\+\).*/\1/")<br />
connected=$(echo $connectedOutputs | wc -w)<br />
<br />
# initialize variables<br />
execute="xrandr "<br />
default="xrandr "<br />
i=1<br />
switch=0<br />
<br />
for display in $connectedOutputs<br />
do<br />
<br />
# build default configuration<br />
if [ $i -eq 1 ]<br />
then<br />
default=$default"--output $display --auto "<br />
else<br />
default=$default"--output $display --off "<br />
fi<br />
<br />
# build "switching" configuration<br />
if [ $switch -eq 1 ]<br />
then<br />
execute=$execute"--output $display --auto "<br />
switch=0<br />
else<br />
execute=$execute"--output $display --off "<br />
fi<br />
<br />
# check whether the next output should be switched on<br />
if [ $display = $activeOutput ]<br />
then<br />
switch=1<br />
fi<br />
<br />
i=$(( $i + 1 ))<br />
<br />
done<br />
<br />
# check if the default setup needs to be executed then run it<br />
echo "Resulting Configuration:"<br />
if [ -z "$(echo $execute | grep "auto")" ]<br />
then<br />
echo "Command: $default"<br />
`$default`<br />
else<br />
echo "Command: $execute"<br />
`$execute`<br />
fi<br />
echo -e "\n$(xrandr)"<br />
</nowiki>}}<br />
<br />
== Using xrandr with VNC ==<br />
If you are using a VNC server that supports xrandr you can change the vnc resolution on the fly by using "xrandr -s <width>x<height>". tigervnc is an example of a client that supports xrandr<br />
<br />
Example:<br />
<br />
xrandr -s 1920x1200<br />
<br />
After you VNC in, if you open a console and type "xrandr" you will get a list of currently configured modes. Each of these modes can be activated with the xrandr -s option; however, if the mode you want does not exist in the list, you can add it by doing the following:<br />
<br />
Example: Say I want to add 1024x600 (a common netbook resolution)<br />
<br />
First run CVT to get the correct modeline for the resolution you want to add<br />
<br />
$ cvt 1024 600<br />
<br />
You will get something like the following output<br />
<br />
# 1024x600 59.85 Hz (CVT) hsync: 37.35 kHz; pclk: 49.00 MHz<br />
Modeline "1024x600_60.00" 49.00 1024 1072 1168 1312 600 603 613 624 -hsync +vsync<br />
<br />
Use that modeline output to run the commands below<br />
<br />
xrandr --newmode "1024x600" 49.00 1024 1072 1168 1312 600 603 613 624 -hsync +vsync<br />
xrandr --addmode default "1024x600"<br />
<br />
Doing the above will give you the ability to change to 1024x600 by typing xrandr -s 1024x600, but it will only last for the current x session. To insure that you can use the newly added resolution each time you start vncserver, add the following to ~/.vnc/xstartup<br />
<br />
xrandr --newmode "1024x600" 49.00 1024 1072 1168 1312 600 603 613 624 -hsync +vsync<br />
xrandr --addmode default "1024x600"<br />
<br />
== See also ==<br />
* https://wiki.ubuntu.com/X/Config/Resolution<br />
* http://bbs.archlinux.org/viewtopic.php?pid=652861<br />
* http://nouveau.freedesktop.org/wiki/Randr12Howto<br />
* http://wiki.debian.org/XStrikeForce/HowToRandR12<br />
* man xrandr</div>Bantuvez