ZNHOO Whatever you are, be a good one!

X

  1. X
  2. Xorg
  3. Video Driver
    1. Hardware Acceleration
  4. KDE
  5. Awesome - Window Manager
  6. Xinit
  7. xserverrc
  8. xinitrc
  9. Automatic startx on login
  10. Touchpad
  11. X Keyboard
  12. SysRq

X

  1. X - window server
    1. Xorg
    2. Wayland
    3. ~/.Xdefaults. Deprecated but used by ancient applications like urxvt. Now replaced by ~/.Xresources. X resources for applications in the form key: value.
    4. ~/.Xmodmap. Set keyboard.
  2. Video Driver
    1. Basic GPU driver
    2. Hardware Acceleration
  3. Window Manager (WM) - manage GUI windows
    1. Awesome
    2. i3
  4. Display Manager (DM) - control graphical login and start WM/DE
    1. SDDM
    2. GDM
    3. ~/.xsessionrc. Config of DM (i.e. choose WM).
    4. ~/.xprofile. General config of X. Equivalent of xinitrc.
  5. xinit/startx - manually start WM/DE
    1. ~/.xinitrc.
      1. General config of X. Equivalent of xprofile.
      2. Set WM.
    2. ~/.xserverrc. Start X server.
  6. Desktop (DE) = WM + DM + more
    1. Xfce
    2. KDE Plasma
    3. Gnome

Xorg

[root@host ~]# pacman -S xorg-server
[root@host ~]# ls -al /usr/bin/X
/usr/bin/X: symboli link to /usr/bin/Xorg

X is the generic name of X Window System display server. The binary X is a symbolic link to the real implementation - Xorg.

Video Driver

Firstly, identify vedio cards:

[root@host ~]# lspci | grep -e VGA -e 3D

The command returns:

Intel HD Graphics 520
NVIDIA GeForce 920M

So the computer has an integrated Intel video card and a discrete NVIDIA video card respectivelly: it is called NVIDIA Optimus. We have several choices to deal with NVIDIA Optimus: turn off one of the video card, use Bumbelee, use Nvidia-xrun etc. Nvidia-xrun is recommended:

Nvidia-xrun is a utility to allow Nvidia optimus enabled laptops run X server with discrete nvidia graphics on demand. This solution offers full GPU utilization, compatibility and better performance than Bumblebee.

If this Arch Linux is a VirtualBox guest, then install VirtualBox guest additions instead.

Check Xorg video driver.

Hardware Acceleration

There are two libraries that support hardware acceleration, namely VA-API and VDPAU. Most applications use the VA-API but we can install both libraries.

For applications that use the VA-API library:

~ $ sudo pacman -S libva-mesa-driver
~ $ vainfo

For applications that use the VDPAU library:

~ $ sudo pacman -S mesa-vdpau
~ $ vdpauinfo

Test:

~ $ mpv --hwdec=auto <video_filename>

KDE

Currently, KDE sucks! This section only shows how to install KDE plasma.

~ $ sudo pacman -S xorg-server
~ $ reboot

~ $ sudo pacman -S plasma-meta
~ $ sudo pacman -S sddm
~ $ systemctl enable sddm

~ $ reboot

It seems that sddm is quite slow to launch Plasma. We need to increase system entropy by haveged and/or rng-tools:

~ $ sudo pacman -S rng-tools
~ $ sudo systemctl enable rngd
~ $ sudo systemctl start rngd

~ $ sudo pacman -S haveged
~ $ systemctl enable haveged
~ $ systemctl start haveged

It might relate to a kernel option unset. However, such hack uses pseudo-random to increase entropy and may leave your system in risks.

Awesome - Window Manager

[root@host ~]# pacman -S awesome
[user@host ~]$ awesome

# E: awesome: main:656: cannot open display (error 5)

Awesome is just a Window Manager. We need Displayer Manager or xinit/startx to launch X server before Window Manager.

Xinit

We don't need a Display Manager.

[root@host ~]# pacman -S xorg-xinit

startx is a wrapper script of xinit that provides some basic settings:

[root@host ~]# cat /usr/bin/startx

xserverrc

xserverrc is the file to start X server, sourced by xinit:

#!/bin/sh

# https://git.edevau.net/onkelbeh/GentooRepository/commit/9d68e491c96541f7cbf3d5766597906561bbf512
if [ -z "${XDG_VTNR}" ]; then
  [[ -t 0 && "$(tty)" == "/dev/tty1" && "$USER" != "root" && -z "$DISPLAY" ]] && exec /usr/bin/X -nolisten tcp -nolisten local -keeptty "$@" vt7
else
  [[ -t 0 && "${XDG_VTNR}" -eq 1 && "$USER" != "root" && -z "$DISPLAY" ]] && exec /usr/bin/X -nolisten tcp -nolisten local -keeptty "$@" vt${XDG_VTNR}
fi

When using a DM, the X server is running as root. The X server log is located at /var/log/Xorg.0.log. However, with xinit, X server is run under normal account. The X server log is located at ~/.local/share/xorg/Xorg.0.log.

  1. The last argument vtXY is the virtual terminal that Xorg will use. By default, X will use the one where it is started.
  2. Xorg -keeptty will redirect log of xinit iteself to Xorg.0.log as well. Check man Xserver and man Xorg for more options.

xinitrc

~/.xinitrc defaults to /etc/X11/xinit/xinitrc. This file is used to launch the DE/WM.

[user@host ~]$ cp /path/to/xinitrc.bak ~/.xinitrc

# ~/.xinitrc

#exec $command
exec awesome

Commands after exec won't be executed as it replace the current shell. If any other commands are required, put them before exec line.

That is enough, just type startx.

Automatic startx on login

Add the following code to ~/.bash_profile:

# auto startx
if shopt -q login_shell; then
  if [ -z "${XDG_VTNR}" ]; then
    [[ -t 0 && "$(tty)" == "/dev/tty1" && "$USER" != "root" && -z "$DISPLAY" ]] && exec startx 2>&1 | tee "$HOME"/.startx.log
  else
    [[ -t 0 && "${XDG_VTNR}" -eq 1 && "$USER" != "root" && -z "$DISPLAY" ]] && exec startx 2>&1 | tee "$HOME"/.startx.log
  fi
fi

We cal also append Xorg options to startx directly like startx -- -keeptty.

Touchpad

xorg-server, by default, depends on and uses xf86-input-libinput for all input devices:

[user@tux ~]$ fgrep -e "Using input driver " ~/.local/share/Xorg/Xorg.0.log
[user@tux ~]$ libinput list-devices
[user@tux ~]$ man 5 xorg.conf ; man 4 libinput

Before configuring Xorg, glimpse at /usr/share/X11/xorg.conf.d and read the INPUTCLASS SECTION of man 5 xorg.conf.

To configure Touchpad, we copy the skeleton from 40-libinput.conf:

[root@tux #]$ cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/30-touchpad.conf
  1. Identifier is any reasonable string specific to the device configured. I choose the exact device name from Xorg log.
  2. Turn on tap to click.
  3. Two-finger click simulates mouse middle buttion.
  4. Three-finger click simulates mouse right button.
  5. When mouse and touchpad events are detected simutaneously, ignore that of mouse.
Section "InputClass"
        Identifier "DLL06F2:00 06CB:75DA Touchpad"
        MatchDevicePath "/dev/input/event*"
        MatchIsTouchpad "on"
        Driver "libinput"
                Option "Tapping" "on"
                Option "TappingButtonMap" "lmr"
                Option "ClickMethod" "clickfinger"
                Option "NaturalScrolling" "true"
                Option "ScrollMethod" "twofinger"
EndSection

Section "InputClass"
        Identifier "Touchpad ignore duplicates"
        MatchDevicePath "/dev/input/mouse*"
        MatchIsTouchpad "on"
        MatchOS "Linux"
                Option "Ignore" "on"
EndSection

X Keyboard

Post archlinux uses /etc/vconsole.conf and/or loadkeys to set keyboard layout for virtual terminal. When it comes to X server, we utilize XkbOptions of Xorg.conf or setxkbmap in .xinitrc.

  1. Basically, I wanna switch 'Caps_Lock' and 'Control_L', or even turn off 'Caps_Lock'.
  2. Check /usr/share/X11/xkb/rules/base.lst for keyboard model (i.e. latitude) and layout (i.e. us).
  3. Run the following command to see similar options:
[root@tux #]$ grep -E "(ctrl|caps):" /usr/share/X11/xkb/rules/base.lst

By Xorg.conf:

# /etc/X11/xorg.conf.d/10-keyboard.conf

Section "InputClass"
        Identifier "Keyboard switch Ctrl and CapsLk"
        MatchIsKeyboard "on"
        Option "XkbOptions" "ctrl:nocaps"
EndSection

By setxkbmap (overrides settings in Xorg.conf):

~/.xinitrc

setxkbmap -model latitude -layout us -option ctrl:swapcaps

SysRq

Check Gentoo SysRq.