Xorg/Guide/zh-cn

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

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

这是新用户遇到的最大惊喜之一: 无非是在您的系统运行的应用程序是一个图形用户界面. 它并非是 '' Linux 内核的一部分或任何其他内部的系统组件. 它只是您的计算机的一个强大工具，完全能使您拥有图形操作的能力.

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

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

X.org 项目
X.org 项目创建和维护 X11 的自由可再发行组件的开源实现系统. 它是开放源码的，基于 X 11 的桌面基础软件.

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

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

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

内核模式设置
现代开源的视频驱动程序依赖于内核模式设置（KMS）. KMS提供了改进的图形化引导少闪烁，更快的用户切换，内置framebuffer终端，从控制台Xorg的无缝切换，和其他功能. KMS与传统的帧缓冲驱动程序，它必须保持disable在你的内核配置冲突.

首先，准备好你的内核为KMS. 你需要考虑你使用它的Xorg视频驱动程序做到这一步.

接下来，配置内核使用正确的KMS驱动程序. 英特尔，NVIDIA和AMD / ATI是最常见的显卡，所以按照代码为下文每张显卡.

对于Intel显卡 :

对于 NVidia 显卡:

For newer AMD/ATI cards (RadeonHD 2000 and up), emerge or. Once one of these packages has been installed, configure the kernel as detailed in the firmware section of Radeon article:

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

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

第一个变量是 VIDEO_CARDS. 这是用于设置你打算使用的视频驱动程序,它通常是基于你的显卡. 对于NVIDIA显卡最常用的配置是： ；对于ATI(AMD)显卡常用的配置是：. NVIDIA和AIT都有积极发展,且支持开源驱动程序.

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

第二个变量设置是： INPUT_DEVICES ，它用于确定需要构建哪些输入设备驱动程序. 在大多数情况下设置他 应该就可以了. 如果您使用其他输入设备,例如笔记本电脑的Synaptics touchpad（触摸板）,一定要将它添加到 INPUT_DEVICES.

决定哪些驱动程序将被使用，然后增加必要的配置到 这个文件:

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

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

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

NVidia 用户
For NVidia users it might be beneficial to run nvidia-xconfig 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 startx.

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

It is both possible and recommended to set the OpenGL renderer to the hardware renderer instead of a software renderer:

配置
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.

Try using startx without editing any configuration files. If Xorg will not start, or there is some other problem, then manual configuration of Xorg will be needed. This is explained in the following section.

目录
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 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 keep them organize. Organization is helpful in when debugging faulty configuration files.

使用 startx
Try to start up the X server. is a script 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:


 * If a file named exists in the home directory, it will execute the commands listed there.


 * Otherwise, it will read the value of the XSESSION variable and will execute one of the sessions available in accordingly. The value of XSESSION can be set in the  file to make a default session for all users on the system. For example, as root, run:




 * This will create the file and set the default X session to Xfce. Remember to run  after making changes to.

If no window manager has been installed a solid black screen will appear. Since this can also be a sign that something is wrong, the and  packages can be installed only to test X.

Once the programs are installed, run startx 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.

设置屏幕分辨率
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 xrandr. Install xrandr (emerge xrandr) just long enough to get this information. The argument after the monitor name (in the  section) must match the   in the   section.

Run X (startx) 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:

The "terminate" command lets users kill the X session by using the ++ key combination. This will, however, make X exit disgracefully -- something that users might want to avoid. It can be useful when programs have frozen the display entirely, or when configuring and tweaking the Xorg environment. Be careful when killing the desktop with this key combination - most programs really do not like it when they are ended this way. Some, if not all, of the information that has not been written to the disk (information stored in "open documents") will be lost.

结束
Run startx</tt> 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.

创建和编辑配置文件
First of all, man xorg.conf</tt> and man evdev</tt> 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!

There are also many online resources on editing config files in. Only a few are listed here; use a choice favorite search engine to find more.

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

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

X.org provides many FAQs on their website, in addition to their other documentation.