X Window System

The X Window System, also just called X or X.org, is an open source implementation of the X Window System. The project is a fork of the XFree86 system. The fork happened in the beginning of 2004 after the license for XFree86 was changed and since 2008, the XFree86 project is inactive. OpenBSD uses the X Window system to provide users with a graphical interface. However, the X Window System itself does not provide a workable environment. A windowmanager, and often Desktop Environment, are needed to create a more hospitable environment. OpenBSD provides multiple window managers, but amongst them are: cwm (Calm Window Manager), fvwm (F* Virtual Window Manager), twm (Tab Window Manager). The default window manager on OpenBSD is cwm.

In terms of architecture, the X Window System is a server client implementation. That means that it’s entirely possible, but often a bad idea due to the security implications, to run the server on one machine, while the client runs on a completely different machine. The most common setup however, is with both server and client running on the same machine.

Configuring X #

In most cases, no manual configuration is needed. Depending on the platform, manual configuration can differ greatly. For example, multiple monitors, or the use of proprietary drivers, can complicate things.

In case of issues, the X log file often provides very useful information pointing in the right direction. The logs will be written to /var/log/Xorg.0.log. Plaform specific instructions can be found in /usr/X11R6/README.

Starting X #

There are two ways to start the X Window System.

$ startx

It’s possible to start X from the command line. This useful for debugging purposes or for infrequent use of a graphical environment.

# rcctl enable xenodm

In order to start the graphical interface by default, enable xenodm. This will cause X to start towards the end of the boot process.

Customizing X #

X can easily be customized. Customization is done via one or two files that are checked once the startx command is invoked.

  1. The command looks for a .xinitrc script in the users home directory. If that file does not exist, a system wide configuration file will be used. That file is located in /etc/X11/xinit/xinitrc.
  2. Once the user has logged in from xenodm, the Xsession script checks for a file named .xsession in the users home directory. This is also the place to start a window manager from. An example .Xsession can be found below. Note that the i3 window manager is started on the last line. Replace i3 with the window manager of your choice.
# use UTF-8 everywhere
export LANG=en_US.UTF-8

# specify location of kshrc
export ENV=$HOME/.kshrc

# load Xresources file
xrdb -merge $HOME/.Xresources

# set your background color
xsetroot -solid dimgray

# xidle will lock your display after a period of inactivity
xidle &

# sadly, xclock has a bug where the font selection is ignored when UTF-8
# is enabled, so we unset LANG here.
#LANG= xclock -strftime "%a %e %b %Y %H:%M" &

# disable system beep
xset b off

# if you have a ThinkPad, the following lines enable TrackPoint
# scrolling by dragging with the middle button.
xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation" 1
xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation Button" 2
xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation Axes" 6 7 4 5

# use caps lock as ctrl key
setxkbmap -option ctrl:nocaps

# start i3!
exec i3