ZNHOO Whatever you are, be a good one!

X

  1. Xorg - An X Server
  2. Awesome - Window Manager
  3. Xinit
  4. xserverrc
  5. xinitrc
  6. Automatic startx on login
  7. Touchpad
  8. X Keyboard
  9. locale

Xorg - An X Server

[root@host ~]# pacman -S xorg-server
[root@host ~]# ls -al /usr/bin/{X,Xorg}
[root@host ~]# man Xserver; man Xorg
  1. There are two providers available for 'libgl': 'libglvnd' and 'nvidia-340xx-utils'. Just choose 'ligblvnd', the default.
  2. Without video driver, Xorg falls back to Kernel Mode Setting (KMS).

Awesome - Window Manager

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

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

Awesome itself does not launch the X server. We need Displayer Manager or Xinit to launch X server before Window Manager.

Xinit

We don't need a Display Manager.

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

startx is front end of xinit that provides a somewhat nicer user interface.

xserverrc

When startx or xinit is invoked, it sources xserverrc file to start and configure X server.

#!/bin/sh

# Compatible with both OpenRC and Systemd
if [ -z "${XDG_VTNR}" ]; then
  exec /usr/bin/X -keeptty -nolisten tcp -nolisten local "$@" vt7
else
  exec /usr/bin/X -keeptty -nolisten tcp -nolisten local "$@" vt${XDG_VTNR}
fi
  1. We should make sure vtXX exist to inhibit bypassing screenlock through 'Ctrl+Alt+Fx'.
  2. -keeptty prevents the X server from detaching its initial controlling terminal. Therefore, output from X session is redirected to Xorg.0.log instead of the virtual terminal.

xinitrc

If ~/.xinitrc is present, startx and xinit execute it. Otherwise startx would check /etc/X11/xinit/xinitrc while xinit has its own defaults (check the man page).

xinitrc, by default, is configured to launch Twm, xorg-xclock and Xterm (assumen these packages are installed). Comment out those items and execute Awesome:

[user@host ~]$ cp /etc/X11/xinit/xinitrc ~/.xinitrc

# ~/.xinitrc

#exec $command
exec awesome
  1. Commands after exec won't be executed as it replace the current shell. If any other commands are required, put them before exec line.
  2. If you decide to write a custom ~/.xinitrc file, then make sure existing ~/.Xresources are loaded like the default does.

That is enough, just type startx. The Xorg log is located at ~/.local/share/Xorg/Xorg.0.log.

Automatic startx on login

Add the following code to ~/.bash_profile:

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

Earlier in this post, /etc/vconsole.conf and/or loadkeys is used to set keyboard layout for virtual console. 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

locale

Uncomment desired locales in /etc/locale.gen:

# /etc/locale.gen

en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GB18030 GB18030
zh_TW.UTF-8 UTF-8
zh_TW BIG5

Generate locales:

[root@archiso / #] grep '^[^#]'/etc/locale.gen
[root@archiso / #] locale-gen
[root@archiso / #] locale -a

The output of locale -a may be different from that of /etc/locale.gen. For example, 'UTF-8' is printed as 'utf8'. To keep compatibility and consistency, use the value specified in /etc/locale.gen instead.

Set system-wide locale:

[root@archiso / #] echo LANG=en_US.UTF-8 >> /etc/locale.conf

Set per-user locale:

# ~/.config/locale.conf

LANG=en_US.UTF-8
LC_COLLATE=C
LANGUAGE=en_US:zh_CN