Difference between revisions of "Xrandr"

From ArchWiki
Jump to: navigation, search
(Scripts: orthograph)
(templates; syntax; reference to "Execute commands after X start"; other fixes)
Line 1: Line 1:
 
[[Category:X Server (English)]]
 
[[Category:X Server (English)]]
Note: credit to and retrieved from https://wiki.ubuntu.com/X/Config/Resolution
+
 
 +
{{Note|credit to and retrieved from the [https://wiki.ubuntu.com/X/Config/Resolution Ubuntu wiki]}}
  
 
== Resetting an out-of-range resolution ==
 
== Resetting an out-of-range resolution ==
  
If you set a resolution inappropriate for your monitor in the <tt>Screen Resolution</tt> GUI tool, you can reset it by running <tt>rm ~/.config/monitors.xml</tt> from a terminal.
+
If you set a resolution inappropriate for your monitor in the {{Codeline|Screen Resolution}} GUI tool, you can reset it by running {{Codeline|rm ~/.config/monitors.xml}} from a terminal.
  
 
== Dynamically testing different resolutions ==
 
== Dynamically testing different resolutions ==
  
You can either use the <tt>Screen Resolution</tt> GUI tool to experiment with different resolutions, or the more powerful xrandr command-line tool:
+
You can either use the {{Codeline|Screen Resolution}} GUI tool to experiment with different resolutions, or the more powerful {{Codeline|xrandr}} command-line tool. It shows you the names of different outputs available on your system (LVDS, VGA-0, etc.) and resolutions available on each:
 
+
<pre>
+
  $ xrandr
+
</pre>
+
 
+
shows you the names of different outputs available on your system (LVDS, VGA-0, etc.) and resolutions available on each:
+
  
<pre>
+
Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 1400 x 1400
Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 1400 x 1400
+
VGA disconnected (normal left inverted right x axis y axis)
VGA disconnected (normal left inverted right x axis y axis)
+
LVDS connected 1400x1050+0+0 (normal left inverted right x axis y axis) 286mm x 214mm
LVDS connected 1400x1050+0+0 (normal left inverted right x axis y axis) 286mm x 214mm
+
    1400x1050      60.0*+  50.0   
  1400x1050      60.0*+  50.0   
+
[...]
[...]
+
</pre>
+
  
 
You can direct xrandr to set a different resolution like this:
 
You can direct xrandr to set a different resolution like this:
  
<pre>
+
   xrandr --output LVDS --mode 1024x768
   $ xrandr --output LVDS --mode 1024x768
+
</pre>
+
  
 
The refresh rate may also be changed, either at the same time or independently:
 
The refresh rate may also be changed, either at the same time or independently:
  
<pre>
+
   xrandr --output LVDS --mode 1024x768 --rate 75
   $ xrandr --output LVDS --mode 1024x768 --rate 75
+
</pre>
+
 
+
Note that changes you make using <tt>xrandr</tt> only last through the current session.  xrandr has a lot more capabilities - see <tt>man xrandr</tt> for details.
+
  
 +
Note that changes you make using {{Codeline|xrandr}} only last through the current session. xrandr has a lot more capabilities - see {{Codeline|man xrandr}} for details.
  
 
== Adding undetected resolutions ==
 
== Adding undetected resolutions ==
  
Due to buggy hardware or drivers, your monitor's correct resolutions may not always be detected. For example, the EDID data block queried from your monitor may be incorrect.
+
Due to buggy hardware or drivers, your monitor's correct resolutions may not always be detected. For example, the EDID data block queried from your monitor may be incorrect.
  
 
If the mode already exists, but just isn't associated for the particular output, you can add it like this:
 
If the mode already exists, but just isn't associated for the particular output, you can add it like this:
  
<pre>
+
   xrandr --addmode S-video 800x600
   $ xrandr --addmode S-video 800x600
+
</pre>
+
  
 
If the mode doesn't yet exist, you'll need to '''create it first''' by specifying a modeline:
 
If the mode doesn't yet exist, you'll need to '''create it first''' by specifying a modeline:
  
<pre>
+
   xrandr --newmode <Mode Line>
   $ xrandr --newmode <Mode Line>
+
</pre>
+
  
You may create a modeline using the <tt>gtf</tt> or <tt>cvt</tt> utility. For example, if you want to add a mode with resolution 800x600, you can enter the following command: (The output is shown following.)
+
You may create a modeline using the {{Codeline|gtf}} or {{Codeline|cvt}} utility. For example, if you want to add a mode with resolution 800x600, you can enter the following command: (The output is shown following.)
  
</pre>
 
 
   $ cvt 800 600
 
   $ cvt 800 600
 
   # 800x600 59.86 Hz (CVT 0.48M3) hsync: 37.35 kHz; pclk: 38.25 MHz
 
   # 800x600 59.86 Hz (CVT 0.48M3) hsync: 37.35 kHz; pclk: 38.25 MHz
 
   Modeline "800x600_60.00"  38.25  800 832 912 1024  600 603 607 624 -hsync +vsync
 
   Modeline "800x600_60.00"  38.25  800 832 912 1024  600 603 607 624 -hsync +vsync
</pre>
 
  
 
Then copy the information after the word "Modeline" into the xrandr command:
 
Then copy the information after the word "Modeline" into the xrandr command:
 +
  xrandr --newmode "800x600_60.00"  38.25  800 832 912 1024  600 603 607 624 -hsync +vsync
  
<pre>
+
== Making xrandr changes persistent ==
  $ xrandr --newmode "800x600_60.00"  38.25  800 832 912 1024  600 603 607 624 -hsync +vsync
+
</pre>
+
  
== Setting xrandr changes persistently ==
+
There are several ways to make xrandr customizations permanent from session to session:
 +
* {{Filename|xorg.conf}} ( Preferred)
 +
* {{Filename|.xprofile}}
 +
* kdm/gdm
  
There are several ways to make xrandr customizations permanent from session to session:  a) .xprofile, b) kdm/gdm, c) xorg.conf.  Each of these mechanisms will be discussed in turn.
+
=== Setting resolution changes in xorg.conf (Preferred) ===
  
=== Setting xrandr commands in .xprofile ===
+
While {{Codeline|xorg.conf}} is largely empty these days, it can still be used for setting up resolutions. For example:
  
A user's <tt>~/.xprofile</tt> file is executed on Xorg startup if it exists and is executable.  You can copy and paste xrandr command line strings into this file so they're executed when you log in.  For example:
+
{{File|name=/etc/X11/xorg.conf|content=
 
+
<pre>
+
  $ xrandr --output VGA-0 --mode 800x600
+
</pre>
+
 
+
There are two disadvantages to using .xprofile for xrandr settings.  First, it occurs fairly late in the startup process, so you'll see some resolution resizing during the initial screen draw; in some cases panel windows may resize improperly as a result.  Second, as this is a per-user setting, it won't affect the resolutions of other users, nor will it alter the resolution on the login screen.
+
 
+
=== Setting xrandr commands in kdm/gdm startup scripts ===
+
 
+
Both KDM and GDM have startup scripts that are executed when X is initiated.  For GDM, these are in /etc/gdm/ , while for KDM this is done at /etc/kde4/kdm/Xsetup.  In either case, you can paste in an xrandr command line string into one of these scripts.  For GDM, try putting them right before
+
<tt>initctl -q emit login-session-start DISPLAY_MANAGER=gdm</tt> in /etc/gdm/Init/Default
+
 
+
This process requires root access and mucking around in system config files, but will take effect earlier in the startup process than using .xprofile, and will apply to all users including the login screen.
+
 
+
=== Setting resolution changes in xorg.conf ===
+
 
+
While <tt>xorg.conf</tt> is largely empty these days, it can still be used for setting up resolutions.  For example:
+
 
+
<pre>
+
 
Section "Monitor"
 
Section "Monitor"
 
     Identifier      "External DVI"
 
     Identifier      "External DVI"
Line 119: Line 84:
 
         Screen          "Primary Screen"
 
         Screen          "Primary Screen"
 
EndSection
 
EndSection
</pre>
+
}}
  
See <tt>man xorg.conf</tt> for full details on how to craft an <tt>xorg.conf</tt> file.
+
See {{Codeline|man xorg.conf}} for full details on how to craft an {{Filename|xorg.conf}} file.
 +
 
 +
=== Setting xrandr commands in xprofile ===
 +
 
 +
See [[Execute commands after X start]].
 +
 
 +
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.
 +
 
 +
=== Setting xrandr commands in kdm/gdm startup scripts ===
 +
 
 +
Both KDM and GDM have startup scripts that are executed when X is initiated. For GDM, these are in {{Filename|/etc/gdm/}} , while for KDM this is done at {{Filename|/etc/kde4/kdm/Xsetup}}.
 +
 
 +
This process requires root access and mucking around in system config files, but will take effect earlier in the startup process than using xprofile.
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Resolution lower than expected ===
  
=== Setting resolution changes in xorg.conf -- resolution lower than expected ===
 
 
==== Try this first ====
 
==== Try this first ====
 +
 
If you video card is recognized but the resolution is lower than you expect, you may try this.
 
If you video card is recognized but the resolution is lower than you expect, you may try this.
  
 
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.
 
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.
  
Change the default xorg.conf
+
Change xorg.conf
<pre>
+
{{File|name=/etc/X11/xorg.conf|content=
Section "Device"
+
        Identifier      "Configured Video Device"
+
EndSection
+
 
+
Section "Monitor"
+
        Identifier      "Configured Monitor"
+
EndSection
+
 
+
 
Section "Screen"
 
Section "Screen"
         Identifier      "Default Screen"
+
         ...
         Monitor        "Configured Monitor"
+
         SubSection "Display"
        Device          "Configured Video Device"
+
                Virtual 3600 1200
EndSection
+
         EndSubSection
</pre>
+
To
+
<pre>
+
Section "Monitor"
+
         Identifier      "Configured Monitor"
+
 
EndSection
 
EndSection
 +
}}
  
Section "Screen"
 
        Identifier      "Default Screen"
 
        Monitor        "Configured Monitor"
 
        Device          "Configured Video Device"
 
->        SubSection "Display"
 
->                Virtual 3600 1200
 
->        EndSubSection
 
EndSection
 
 
Section "Device"
 
        Identifier      "Configured Video Device"
 
EndSection
 
</pre>
 
 
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).
 
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).
  
 
==== Use cvt/xrandr tool to add the highest mode the LCD can do ====
 
==== Use cvt/xrandr tool to add the highest mode the LCD can do ====
 +
 
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
 
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
<pre>
+
$ cvt 1920 1200 60
aa@aa-desktop:/$ cvt 1920 1200 60
+
# 1920x1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz
# 1920x1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz
+
Modeline "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync
Modeline "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync
+
$ cvt 1680 1050 60
aa@aa-desktop:/$ cvt 1680 1050 60
+
# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
+
Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
+
$ xrandr --newmode "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync
aa@aa-desktop:/$ xrandr --newmode "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync
+
$ xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
aa@aa-desktop:/$ xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
+
$ xrandr --addmode DVI-1 "1920x1200_60.00"
aa@aa-desktop:/$ xrandr --addmode DVI-1 "1920x1200_60.00"
+
$ xrandr --addmode DVI-0 "1680x1050_60.00"
aa@aa-desktop:/$ xrandr --addmode DVI-0 "1680x1050_60.00"
+
</pre>
+
  
 
== Obtaining modelines from Windows program PowerStrip ==
 
== Obtaining modelines from Windows program PowerStrip ==
  
X.Org Wiki [[http://www.x.org/wiki/FAQVideoModes#head-82230a582646cbf28ac41dec2139732ee868e0d2|has an article about this]].
+
[http://www.x.org/wiki/FAQVideoModes#ObtainingmodelinesfromWindowsprogramPowerStrip Obtaining modelines from Windows program PowerStrip].
  
== Scripts ==  
+
== Scripts ==
{{File|name=~/bin/xdisplay|content=
+
 
#!/bin/bash  
+
{{File|name=~/bin/xdisplay|content=<nowiki>
 +
#!/bin/bash
 +
#
 +
# This script toggles the extended monitor outputs if something is connected
 
#
 
#
# This script toggles the extended monitor
 
# outputs if something is connected
 
#
 
#
 
  
# your notebook monitor  
+
# your notebook monitor
 
DEFAULT_OUTPUT='LVDS1'
 
DEFAULT_OUTPUT='LVDS1'
  
Line 200: Line 154:
 
OUTPUTS='VGA1 HDMI1'
 
OUTPUTS='VGA1 HDMI1'
  
# get info from xrandr  
+
# get info from xrandr
 
XRANDR=`xrandr`
 
XRANDR=`xrandr`
  
Line 221: Line 175:
  
 
xrandr --output $DEFAULT_OUTPUT --auto $EXECUTE
 
xrandr --output $DEFAULT_OUTPUT --auto $EXECUTE
 
+
</nowiki>}}
}}
+

Revision as of 23:24, 29 July 2010


Note: credit to and retrieved from the Ubuntu wiki

Resetting an out-of-range resolution

If you set a resolution inappropriate for your monitor in the Template:Codeline GUI tool, you can reset it by running Template:Codeline from a terminal.

Dynamically testing different resolutions

You can either use the Template:Codeline GUI tool to experiment with different resolutions, or the more powerful Template:Codeline command-line tool. It shows you the names of different outputs available on your system (LVDS, VGA-0, etc.) and resolutions available on each:

Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 1400 x 1400
VGA disconnected (normal left inverted right x axis y axis)
LVDS connected 1400x1050+0+0 (normal left inverted right x axis y axis) 286mm x 214mm
   1400x1050      60.0*+   50.0  
[...]

You can direct xrandr to set a different resolution like this:

 xrandr --output LVDS --mode 1024x768

The refresh rate may also be changed, either at the same time or independently:

 xrandr --output LVDS --mode 1024x768 --rate 75

Note that changes you make using Template:Codeline only last through the current session. xrandr has a lot more capabilities - see Template:Codeline for details.

Adding undetected resolutions

Due to buggy hardware or drivers, your monitor's correct resolutions may not always be detected. For example, the EDID data block queried from your monitor may be incorrect.

If the mode already exists, but just isn't associated for the particular output, you can add it like this:

 xrandr --addmode S-video 800x600

If the mode doesn't yet exist, you'll need to create it first by specifying a modeline:

 xrandr --newmode <Mode Line>

You may create a modeline using the Template:Codeline or Template:Codeline utility. For example, if you want to add a mode with resolution 800x600, you can enter the following command: (The output is shown following.)

 $ cvt 800 600
 # 800x600 59.86 Hz (CVT 0.48M3) hsync: 37.35 kHz; pclk: 38.25 MHz
 Modeline "800x600_60.00"   38.25  800 832 912 1024  600 603 607 624 -hsync +vsync

Then copy the information after the word "Modeline" into the xrandr command:

 xrandr --newmode "800x600_60.00"   38.25  800 832 912 1024  600 603 607 624 -hsync +vsync

Making xrandr changes persistent

There are several ways to make xrandr customizations permanent from session to session:

Setting resolution changes in xorg.conf (Preferred)

While Template:Codeline is largely empty these days, it can still be used for setting up resolutions. For example:

Template:File

See Template:Codeline for full details on how to craft an Template:Filename file.

Setting xrandr commands in xprofile

See Execute commands after X start.

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.

Setting xrandr commands in kdm/gdm startup scripts

Both KDM and GDM have startup scripts that are executed when X is initiated. For GDM, these are in Template:Filename , while for KDM this is done at Template:Filename.

This process requires root access and mucking around in system config files, but will take effect earlier in the startup process than using xprofile.

Troubleshooting

Resolution lower than expected

Try this first

If you video card is recognized but the resolution is lower than you expect, you may try this.

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.

Change xorg.conf Template:File

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).

Use cvt/xrandr tool to add the highest mode the LCD can do

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

$ cvt 1920 1200 60
# 1920x1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz
Modeline "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync
$ cvt 1680 1050 60
# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
$ xrandr --newmode "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync
$ xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
$ xrandr --addmode DVI-1 "1920x1200_60.00"
$ xrandr --addmode DVI-0 "1680x1050_60.00"

Obtaining modelines from Windows program PowerStrip

Obtaining modelines from Windows program PowerStrip.

Scripts

Template:File