X
11 Mar 2019 • Leave Comments- X
- Xorg
- Video Driver
- KDE
- Awesome - Window Manager
- Xinit
- xserverrc
- xinitrc
- Automatic startx on login
- Touchpad
- XKB
- SysRq
X
- X - window server
- Xorg
- Wayland
- ~/.Xdefaults. Deprecated but used by ancient applications like urxvt. Now replaced by ~/.Xresources. X resources for applications in the form
key: value
. - ~/.Xmodmap. Deprecated by XKB (either through setxkbmap or directly in Xorg conf).
- Video Driver
- Basic GPU driver
- Hardware Acceleration
- Window Manager (WM) - manage GUI windows
- Awesome
- i3
- Display Manager (DM) - control graphical login and start WM/DE
- SDDM
- GDM
- ~/.xsessionrc. Config of DM (i.e. choose WM).
- ~/.xprofile. General config of X. Equivalent of xinitrc.
- xinit/startx - manually start WM/DE
- ~/.xinitrc.
- General config of X. Equivalent of xprofile.
- Set WM.
- ~/.xserverrc. Start X server.
- ~/.xinitrc.
- Desktop (DE) = WM + DM + more
- Xfce
- KDE Plasma
- 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.
- The last argument
vtXY
is the virtual terminal that Xorg will use. By default, X will use the one where it is started. - Xorg
-keeptty
will redirect log of xinit iteself to Xorg.0.log as well. Checkman Xserver
andman 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
- Identifier is any reasonable string specific to the device configured. I choose the exact device name from Xorg log.
- Turn on tap to click.
- Two-finger click simulates mouse middle buttion.
- Three-finger click simulates mouse right button.
- 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
XKB
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.
- Basically, I wanna switch 'Caps_Lock' and 'Control_L', or even turn off 'Caps_Lock'.
- Check /usr/share/X11/xkb/rules/base.lst for keyboard model (i.e. latitude) and layout (i.e. us).
- 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) in ~/.xinitrc or ~/.xprofile.
setxkbmap -model latitude -layout us -option ctrl:swapcaps
SysRq
Check Gentoo SysRq.