Xorg/Guide/zh-cn

Xorg是X Window server ，它允许用户在他们的指尖创造一个图形环境. 本指南解释了什么是Xorg，如何安装它，以及各种配置选项.

图形VS命令行
一般来说，大多数用户可能都点有害怕敲命令的想法. 它为什么不能够按照自己的方式，指向和点击命令？这难道不是（和通常的Linux发行版）Gentoo提供的自由吗？嗯，当然，你可以做到这一点！ Linux提供了许多优秀的用户界面和环境，你可以在现有的系统基础上进行安装.

这是新用户感到的最大惊喜之一: 在您的系统上运行的图形界面只不过是一个应用程序而且. 它“并非”是Linux 内核的一部分或任何其他内部的系统组件. 它是你的工作站的一个强大工具，并能使您拥有完全的图形化操作能力.

标准是重要的，一个标准的绘图和窗口是在屏幕上移动,通过鼠标，键盘和其他基本的东西，重要的方面用户交互的标准，并命名为“”X Window System'，通常简称为X11或只是X. 它被世界各地的Unix，Linux和Unix类操作系统广泛使用.

这个程序为Linux用户提供运行图形界面的能力，Xorg-X11使用X11的接口和标准，是XFree86项目的一个分支. XFree86使用的许可证，可能无法与GPL许可兼容；因我们此建议使用Xorg. 且官方的Portage树不再提供XFree86包.

X.org 项目
X.org 项目创建和维护一个自由、可再发行的组件、开源的 X11. 它是一个开放源码，基于X11-based的桌面所需要的基本软件.

Xorg在一个你想运行的，硬件和图形软件之间提供了一个接口. 除此之外，Xorg也是一个完全的Network-aware，这意味着你可以运行一个应用程序在一个系统上,并且还能同时查看其他不同的系统.

安装
安装Xorg之前，你需要准备好你的系统. 首先，我们将设置内核，使其支持输入设备和显卡. 然后，我们做好准备，配置 ，使驱动程序和Xorg包正确编译并安装.

输入驱动程序支持
默认情况下，Xorg 使用 ，它是一个通用的输入驱动程序. 您将需要通过对您的内核配置更改，来激活对 的支持. 如果你不知道如何配置你的内核，请看Kernel Configuration Guide

内核模块设置
现代开源的视频驱动程序依赖于内核模块设置（KMS）. KMS提供了改进的图形化引导，更快的用户切换，内置framebuffer终端，从控制台Xorg的无缝切换，和其他功能.

首先，准备为你的内核准备好KMS. 你要做这一步,无论你正在使用哪个Xorg显卡驱动程序.

接下来，配置内核使用正确的KMS驱动. Intel，NVIDIA和AMD / ATI是最常见的显卡，所以接下来请按照您自己的显卡来操作.

对于Intel显卡请看kernel section of the Intel article.

对于 NVidia 显卡:

对于新的 AMD/ATI 显卡 (RadeonHD 2000 and up)，emerge 或. 一旦其中的某个包被安装，在firmware section 关于 Radeon article配置详细的内核参数：

退出内核配置 重建内核，并重新启动.

现在KMS已经被设置，继续准备下一节，修改.

make.conf 配置
现在内核已经配置好了，但是两个重要的变量必须在你安装Xorg之前，在进行配置.

The first variable is VIDEO_CARDS. This is used to set the video drivers that you intend to use and is usually based on the kind of video card you have. The most common settings are  for nVidia cards or   for ATI cards. Both have actively developed, well-supported open-source drivers.

驱动程序可用于台式机或笔记本电脑常见的英特尔集成显卡芯片组.

The second variable is INPUT_DEVICES and is used to determine which drivers are to be built for input devices. In most cases setting it to  should work just fine. If you use alternative input devices, such as a Synaptics touchpad for a laptop, be sure to add it to INPUT_DEVICES.

Decide which drivers will be used and add necessary settings to the file:

如果推荐的设置不起作用，emerge （请参阅下面的步骤）. 检查所有可用的选项，并选择适用于该系统的那些选项. 这个例子是用于使用键盘，鼠标，Synaptics触摸板，以及Radeon显卡的系统配置.

设置好所有必需的变量后，我们可以安装Xorg了：

当安装完成后，在继续之前一些环境变量将需要重新初始化. 更新profile配置文件命令：

NVidia 用户
For NVidia users it might be beneficial to run in order to generate a working  file for the selected graphics card. Without this step the file will need to be created manually as described below. Missing the will sometimes generate a "No screens found" error to the terminal when attempting to.

Also the NVidia driver will only work after a reboot, so be sure to restart the system after running.

如果可能的话，建议设置使用OpenGL渲染硬件渲染器，而不是软件渲染器：

配置
The X server is designed to work out-of-the-box, with no need to manually edit Xorg's configuration files. It should detect and configure devices such as displays, keyboards, and mice.

试试using startx 而不是去直接编辑配置文件. 如果Xorg无法启动，那么可能有其他问题，此时，你将需要再去手动编辑Xorg配置. 这在下面的部分进行说明.

目录
Most of the configuration files for Xorg are stored in. Each file is given a unique name and ends in. The file names in Xorg's configuration directory will be read in alpha numeric order. For example, will be read before ;  will be read before, and so on. The files in this directory are not required to be numbered, but doing so will help to keep them organized. Organization is helpful when debugging faulty configuration files.

使用 startx
Try to start up the X server. is a script (it's installed by ) that executes an X session; that is, it starts the X server and some graphical applications on top of it. It decides which applications to run using the following logic:


 * 如果一个叫做的文件存在于主目录（home）中，它会执行里面列出的命令.


 * Otherwise, it will read the value of the XSESSION variable from the file and execute the relevant session accordingly. Values for XSESSION are available in . To set a system wide default session run:




 * 这将创建文件：，然后设置默认X会话Xfce. 记得在修过后，执行命令.

如果你没有安装窗口管理器，那么一个纯黑色的屏幕将会出现，此后这也可以说明，哪些东西发生了错误. 和 包可以用来测试X是否正常配置.

Once the programs are installed, run again. A few windows should appear, making it easy to verify the X server is working correctly. Once satisfied with the results, unmerge and  if installed in the step above to remove the testing packages. They will not be needed to setup a proper desktop environment.

The session (program to start) could also be given as an argument to :

You can also pass X11 server options, by preceding them with a double dash:

设置屏幕分辨率
If the screen resolution looks to be wrong, you will need to check two sections in your configuration. First of all, you have the Screen section which lists the resolutions that your X server will run at. This section might not list any resolutions at all. If this is the case, Xorg will estimate the resolutions based on the information in the second section, Monitor.

Now let us change the resolution. In the next example from we add the   line so that our X server starts at 1440x900 by default. The  in the   section must match the name of your monitor, which can be obtained by running. Install  just long enough to get this information. The argument after the monitor name (in the  section) must match the   in the   section.

Run X to discover it uses the desired resolution.

多显示器
More than one monitor in can be established in. Give each monitor a unique identifier, then list its physical position, such as "RightOf" or "Above" another monitor. The following example shows how to configure a DVI and a VGA monitor, with the VGA monitor as the right-hand screen:

配置键盘
To setup X to use an international keyboard create the appropriate config file in. This example features a Czech keyboard layout:

For methods of switching the keyboard layout see the Keyboard layout switching article.

"终止"命令 允许用户通过使用++ 组合键来结束X会话. 不过，这样退出不怎么好 -- 用户应该尽量避免这样做. 但它在程序完全卡死或配置和调整 Xorg环境时很有用. 请谨慎使用，通过该组合键结束桌面 — — 大多数程序真的不喜欢以这种方式结束. 一些文件，比如尚未写入磁盘（比如存储在“已打开的文档”中的信息）中的数据，将丢失.

即将完成
Run and be happy about the result. Congratulations, you now (hopefully) have a working Xorg! The next step is to install a useful window manager or desktop environment such as KDE, GNOME, or Xfce. Information on installing these desktop environments can be found here on the wiki.

参考

 * Wayland - The next generation window manager for Linux.
 * X (Security Handbook) - The Security Handbook's entry on securing the X server.

创建和编辑配置文件
First of all, and  provide quick yet complete references about the syntax used by these configuration files. Be sure to have them open on a terminal when editing Xorg configuration files!

在编辑配置文件中的也有许多在线资源：. 只有少数列出在这里;可以选择你最喜爱的搜索引擎来找到更多指导.

其他资源
More information about installing and configuring various graphical desktop environments and applications can be found in the section of our documentation.

When upgrading to xorg-server 1.9 or higher, be sure to read the migration guide.

除了我们这些文档，在他们自己的网站上，X.org还提供许多FAQs