Xorg/Guide/pl

From Gentoo Wiki
< Xorg
Jump to:navigation Jump to:search
This page is a translated version of the page Xorg/Guide and the translation is 0% complete.
Outdated translations are marked like this.

Xorg is the X Window server which allows users to have a graphical environment at their fingertips. This guide explains what Xorg is, how to install it, and the various configuration options.

See also
Xorg and X server articles.

Graphical vs command-line

An average user may be frightened at the thought of having to type in commands at a command-line interface (CLI). Why wouldn't they be able to point-and-click their way through the freedom provided by Gentoo (and Linux in general)? Well, of course they can!

Gentoo offers a wide variety of flashy graphical interfaces such as window managers and desktop environments which can be installed on top of an existing installation.

One of the biggest surprises users who are new to Linux come across: graphical user interfaces are nothing more than an application (or in some cases a suite of applications) which are run on a system. It is not part of the Linux kernel or any other internals of the system. That said, GUIs are powerful tools that unlock the graphical abilities of a workstation.

As standards are important, a standard for drawing and moving windows on a screen, interacting with the user through mouse, keyboard, and other basic, yet important aspects has been created and named the X Window System, commonly abbreviated as X11 or just X. It is used on Unix, Linux, and Unix-like operating systems throughout the world.

The application that provides Linux users with the ability to run graphical user interfaces and that uses the X11 standard is Xorg-X11, a fork of the XFree86 project. XFree86 has decided to use a license that might not be compatible with the GPL license; the use of Xorg is therefore recommended. XFree86 packages are no longer provided through the Gentoo repository.

The X.org project

The X.org project created and maintains a freely redistributable, open-source implementation of the X11 system. It is an open source X11-based desktop infrastructure.

Xorg provides an interface between hardware and the graphical software. Besides that, Xorg is also fully network-aware, allowing to run an application on one system while viewing it on a different one.

Installation

Before installing Xorg, prepare the system for it. First, set up the kernel to support input devices and video cards. Then, prepare /etc/portage/make.conf so that the right drivers and Xorg packages are built and installed.

Input driver support

Support for Event interface (CONFIG_INPUT_EVDEV) needs to be activated by making a change to the kernel configuration. Read the Kernel Configuration Guide for information on how to setup the kernel.

KERNEL Enabling evdev in the kernel
Device Drivers --->
  Input device support --->
  <*>  Event interface

Kernel modesetting

Modern open source video drivers rely on kernel mode setting (KMS). KMS provides an improved graphical boot with less flickering, faster user switching, a built-in framebuffer console, seamless switching from the console to Xorg, and other features.

Verify legacy framebuffer drivers have been disabled

Ważne
KMS conflicts with legacy framebuffer drivers, which must remain disabled in the kernel configuration.

First prepare the kernel for KMS. This step regardless of which Xorg video driver will be used:

KERNEL Disable legacy framebuffer support and enable basic console FB support
Device Drivers --->
   Graphics support --->
      Frame Buffer Devices --->
         <*> Support for frame buffer devices --->
         ## (Disable all drivers, including VGA, Intel, NVIDIA, and ATI, except EFI-based Framebuffer Support, only if you are using UEFI)
 
      ## (Further down, enable basic console support. KMS uses this.)
      Console display driver support --->
         <*>  Framebuffer Console Support

Next configure the kernel to use the proper KMS driver for the video card. Intel, NVIDIA, and AMD/ATI are the most common cards, so follow code listing for each card below.

Intel

For Intel cards see the kernel section of the Intel article.

NVIDIA

For NVIDIA cards, two driver options are available. For a full open source system, an open source driver entitled Nouveau is suggested. The second option is the closed source NVIDIA driver, which is officially supported by NVIDIA. This article recommends the Nouveau driver, however be aware not all functionality for certain cards may be supported using the open source driver.

In addition to the kernel driver, certain cards require closed source firmware to be built-in to the Linux kernel. Depending on the selected driver, readers should visit each respective article to check to see if firmware (from the sys-kernel/linux-firmware is necessary for their specific card.

KERNEL NVIDIA kernel
Device Drivers --->
   Graphics support --->
      <M/*>  Nouveau (NVIDIA) cards

AMD/ATI

For newer AMD/ATI cards (RadeonHD 2000 and up), emerge sys-kernel/linux-firmware (the package includes firmware for radeon and amdgpu drivers). Once one of these packages has been installed, make the Radeon driver a module in the kernel or, optionally, configure the kernel as detailed in the firmware section of the Radeon article or, for newer AMD graphics cards (GCN1.1+), the firmware section of the AMDGPU article.

Older cards:

KERNEL AMD/ATI Radeon settings
## (Setup the kernel to use the radeon-ucode firmware, optional if "ATI Radeon" below is M)
Device Drivers --->
   Generic Driver Options --->
   [*]  Include in-kernel firmware blobs in kernel binary
  ## # ATI card specific, (see Radeon page for details which firmware files to include)
   (radeon/<CARD-MODEL>.bin ...)
  ## # Specify the root directory
   (/lib/firmware/) External firmware blobs to build into the kernel binary
 
## (Enable Radeon KMS support)
Device Drivers --->
   Graphics support --->
   <M/*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
   <M/*>    ATI Radeon
   [*]      Enable modesetting on radeon by default
   [ ]      Enable userspace modesetting on radeon (DEPRECATED)

Newer cards:

KERNEL AMDGPU settings
## (Setup the kernel to use the amdgpu firmware, optional if "AMD GPU" below is M)
Device Drivers --->
   Generic Driver Options --->
   [*]  Include in-kernel firmware blobs in kernel binary
  ## # AMD card specific, (see AMDGPU page for details which firmware files to include)
   (amdgpu/<CARD-MODEL>.bin ...)
  ## # Specify the root directory
   (/lib/firmware/) External firmware blobs to build into the kernel binary
 
## (Enable Radeon KMS support)
Device Drivers --->
   Graphics support --->
   <M/*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
   <M/*> AMD GPU
         [ /*] Enable amdgpu support for SI parts
         [ /*] Enable amdgpu support for CIK parts 
         [*]   Enable AMD powerplay component  
         ACP (Audio CoProcessor) Configuration  ---> 
             [*] Enable AMD Audio CoProcessor IP support (CONFIG_DRM_AMD_ACP)
         Display Engine Configuration  --->
             [*] AMD DC - Enable new display engine
             [ /*] DC support for Polaris and older ASICs
             [ /*] AMD FBC - Enable Frame Buffer Compression
             [ /*] DCN 1.0 Raven family
   <M/*> HSA kernel driver for AMD GPU devices
Informacja
On x86/amd64, older Radeon cards (X1900 series and older) do not need extra firmware or any special firmware configuration. Direct Rendering Manager (DRM) and ATI Radeon modesetting driver are the only kernel settings necessary for correct operation.
Informacja
Linux kernel >= 3.9 does not have the Enable modesetting on radeon by default since it is already implied by default. Do not be alarmed if this option is missing in new kernels.
Informacja
Linux kernel >= 4.15 does include Display Core (DC) which is required for AMDGPU to work. This newer driver was written for GCN5.0 Vega and DCN1.0 Raven Ridge (APU), but also adds additional functionality for older Radeon graphics cards starting with GCN1.1 Southern Islands and newer. It is planned to make this additional support for older Radeon cards the standard, so do not be alarmed if this option is missing in newer kernels.

Exit the kernel configuration, rebuild the kernel, and reboot.

Now that KMS has been set up, continue preparing /etc/portage/make.conf in the next section.

Now that the kernel is prepared, some variables in the /etc/portage/make.conf file must be configured before installing Xorg.

make.conf

Portage knows the X USE flag for enabling support for X in other packages (default in all desktop profiles). Make sure this USE flag is added to the USE flag list to ensure X compatibility system wide:

FILE /etc/portage/make.conf
USE="X"

The first variable is VIDEO_CARDS. This is used to set the video drivers that intended to be used, and is usually based on the kind of video card present. The most common settings are nouveau for NVIDIA cards or radeon for AMD cards. Both have actively developed, well-supported open-source drivers. For newer AMD video cards (Southern Islands and up), there is also the open-source amdgpu driver. See the AMDGPU article for more details.

Informacja
There are also the proprietary drivers from NVIDIA and AMD/ATI, nvidia and fglrx respectively. However, setting up the proprietary drivers is beyond the scope of this guide. Please read the Gentoo Linux NVIDIA Guide and Gentoo Linux ATI FAQ. If refer to these guides for more information, and advice on choosing the driver.

The intel driver may be used for desktops or laptops with common Intel integrated graphics chipsets. See Intel X Drivers for more details.

Informacja
The VIDEO_CARDS variable may contain more than one value as long as each value is separated by a space.

The second variable is INPUT_DEVICES and is used to determine which drivers are to be built for input devices.

make.defaults has Libinput as the default input device driver.

To check what is presently set, run:

user $portageq envvar INPUT_DEVICES

In case alternative input devices, such as a Synaptics touchpad for a laptop are needed, be sure to add them to INPUT_DEVICES the /etc/portage/make.conf file:

CODE Sample make.conf entries
## (For mouse, keyboard, and Synaptics touchpad support)
INPUT_DEVICES="libinput synaptics"
## (For NVIDIA cards)
VIDEO_CARDS="nouveau"
## (For AMD/ATI cards)
VIDEO_CARDS="radeon"

If the suggested settings does not work emerge the x11-base/xorg-drivers package (see the step below). Check all the options available and choose those which apply to the system. This example is for a system with a keyboard, mouse, Synaptics touchpad, and a Radeon video card.

root #emerge --pretend --verbose x11-base/xorg-drivers
 
These are the packages that would be merged, in order:
 
Calculating dependencies... done!
[ebuild   R   ] x11-base/xorg-drivers-1.20-r1::gentoo  INPUT_DEVICES="libinput synaptics -elographics -evdev -joystick -keyboard -mouse -vmmouse -void -wacom" VIDEO_CARDS="nouveau radeon -amdgpu -ast -dummy -fbdev (-freedreno) (-geode) -glint -i915 -i965 -intel -mga -nv -nvidia (-omap) -qxl -r128 -radeonsi -siliconmotion (-tegra) (-vc4) -vesa -via -virtualbox -vmware" 0 KiB

The USE flags have the following meaning:

USE flags for x11-base/xorg-server X.Org X servers

+elogind Use elogind to get control over framebuffer when running as regular user
+udev Enable virtual/udev integration (device discovery, power and storage device support, etc)
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
minimal Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
suid Enable setuid root program(s)
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
unwind Enable libunwind usage for backtraces
xcsecurity Build Security extension
xephyr Build the Xephyr server
xnest Build the Xnest server
xorg Build the Xorg X server (HIGHLY RECOMMENDED)
xvfb Build the Xvfb server

Informacja
By default the suid USE flag is disabled, which is fine when, as per recommendation, X runs under a logind provider like elogind, or systemd. The suid USE flag should however be enabled in /etc/portage/package.use/xorg-server in case no logind provider is used and X is run under a normal user account, e.g. started with startx. Please see also this repository news article. Setting suid would then prevent permission errors on /dev/tty0, or on virtual console 7.

Emerge

After setting all the necessary variables and USE flags Xorg can be installed:

root #emerge --ask x11-base/xorg-server

When the installation is finished, some environment variables will need to re-initialized before continuing. Source the profile with this command:

root #env-update
root #source /etc/profile

Configuration

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 might be needed. This is explained in the following section.

To run Xorg with non-root users, as root, either enable a logind provider (see Non root Xorg) or set the suid USE flag (see above note).

Informacja
If changes have been made to the kernel, do not forget to restart the system before using startx in order to be using the newly built kernel. If the kernel was updated to a newer version in the process this will most likely require the bootloader's configuration files to be updated as well.

The xorg.conf.d directory

Ważne
Configuring files in xorg.conf.d should be seen as a last resort option. If possible it is desirable to run Xorg without any special configuration.

Most of the configuration files for Xorg are stored in /etc/X11/xorg.conf.d/. If that directory does not exist, then create it. Each file is given a unique name and ends in .conf. The file names in Xorg's configuration directory will be read in alpha numeric order. For example, 10-evdev.conf will be read before 20-synaptics.conf; a-evdev.conf will be read before b-synaptics.conf, 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.

Informacja
Xorg provides example configurations in /usr/share/doc/xorg-server-${version}/xorg.conf.example.bz2. These can be used to create custom configuration files in /etc/X11/xorg.conf.d/. The examples are heavily commented, but if more documentation regarding the syntax is needed, man xorg.conf is always available. Other examples can be found in the section Other resources at the end of this guide.

Using startx

Try startx to start up the X server. startx is a script (it's installed by x11-apps/xinit) 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 .xinitrc exists in the home directory, it will execute the commands listed there.
  • Otherwise, it will read the value of the XSESSION variable from the /etc/env.d/90xsession file and execute the relevant session accordingly. Values for XSESSION are available in /etc/X11/Sessions/. To set a system wide default session run:
root #echo XSESSION="Xfce4" > /etc/env.d/90xsession
This will create the 90xsession file and set the default X session to Xfce. Remember to run env-update after making changes to 90xsession.
user $startx

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 x11-wm/twm and x11-terms/xterm packages can be installed only to test X.

Once the programs are installed, run startx again. A few xterm windows should appear, making it easy to verify the X server is working correctly. Once satisfied with the results, depclean x11-wm/twm and x11-terms/xterm 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 startx:

user $startx /usr/bin/startfluxbox

In addition, to pass X11 server options, by preceding them with a double dash:

user $startx -- vt7

Tweaking X settings

Setting the screen resolution

If the screen resolution looks to be wrong, check two sections in xorg.conf.d configuration. First of all, the Screen section lists the resolutions that the 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 change the resolution. In the next example from /etc/X11/xorg.conf.d/40-monitor.conf we add the PreferredMode line so that the X server starts at 1440x900 by default. The Option in the Device section must match the name of the monitor (DVI-0), 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 Device section) must match the Identifier in the Monitor section.

FILE /etc/X11/xorg.conf.d/40-monitor.conf
Section "Device"
  Identifier  "RadeonHD 4550"
  Option      "Monitor-DVI-0" "DVI screen"
EndSection
Section "Monitor"
  Identifier  "DVI screen"
  Option      "PreferredMode" "1440x900"
EndSection

Run X (startx) to discover it uses the desired resolution.

Multiple monitors

More than one monitor in can be established in /etc/X11/xorg.conf.d/. 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:

FILE /etc/X11/xorg.conf.d/40-monitor.conf
Section "Device"
  Identifier "RadeonHD 4550"
  Option     "Monitor-DVI-0" "DVI screen"
  Option     "Monitor-VGA-0" "VGA screen"
EndSection
Section "Monitor"
  Identifier "DVI screen"
EndSection
Section "Monitor"
  Identifier "VGA screen"
  Option     "RightOf" "DVI screen"
EndSection

Configuring the keyboard

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

Informacja
The rest of this section may not be needed if following the Keyboard layout switching article.

To setup X to use an international keyboard create the appropriate config file in /etc/X11/xorg.conf.d/. This example features a Czech keyboard layout:

FILE /etc/X11/xorg.conf.d/30-keyboard.conf
Section "InputClass"
  Identifier "keyboard-all"
  Driver "evdev"
  MatchProduct "AT Translated Set 2 keyboard"    # apply to devices having this as a substring
  MatchIsKeyboard "true"                         # apply to "keyboard" devices only
  Option "XkbLayout" "us,cz"
  Option "XkbModel" "logitech_g15"
  Option "XkbRules" "xorg"
  Option "XkbOptions" "grp:alt_shift_toggle,grp:switch,grp_led:scroll,compose:rwin,terminate:ctrl_alt_bksp"
  Option "XkbVariant" ",qwerty"
  MatchIsKeyboard "on"
EndSection

The "terminate" command (terminate:ctrl_alt_bksp) lets users kill the X session by using the Ctrl+Alt+Backspace 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.

Because the "evdev" driver can handle multiple devices (even non-keyboards), limiting the section to only some devices might be needed for proper working of all the devices. Use the MatchProduct directive to specify the device name, consult man xorg.conf for more info.

For more information about XkbModel and XkbOptions, consult /usr/share/X11/xkb/rules/base.lst and man xkeyboard-config.

Finishing up

Run startx and be happy about the result. There should now be a (hopefully) 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.

See also

  • Non root Xorg — describes how an unprivileged user can run Xorg without using suid.
  • Wayland — a replacement for the X11 window system protocol and architecture with the aim to be easier to develop, extend, and maintain
  • X (Security Handbook) - The Security Handbook's entry on securing the X server.
  • Xorg — an open source implementation of the X server.
  • Xorg/Guide — explains what Xorg is, how to install it, and the various configuration options.
  • XrandrX protocol extension and its CLI tool xrandr are used to manage screen resolutions, rotation and screens with multiply displays in X
  • X server — the main component of the X Window system which abstracts the hardware and provides the foundation for most graphical user interfaces, like desktop environments or window managers, and their applications.

External resources

Creating and editing config files

man xorg.conf and man evdev 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!

Example configurations can be found at /usr/share/doc/xorg-server-*/xorg.conf.example.bz2.

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

Other resources

More information about installing and configuring various graphical desktop environments and applications can be found in the Gentoo desktop 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.


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Sven Vermeulen (SwifT) , Joshua Saddler(nightmorph)
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.