DragonFly BSD


The X Window System

This chapter will cover the usual way of giving your Dragonfly BSD system an X Window style Graphical User Interface (GUI).

Before reading this chapter, install xorg, xdm and cwm packages.

Introduction to X

The X Window System (sometimes just called "X") is the environment which provides graphics services to DragonFly BSD and other Unix-based systems. By itself, X provides very little, since one also must have a window manager to present a user interface. The X11 specification is an open standard, and there are different implementations, some commercial, and some free. X.org is the free implementation of the X11 specification.

It is possible to run X clients on a system without any graphical support. For example, one could have an application (the X client) running on an ARM system, displaying its output on an amd64's graphical display (the X server). Since X is a well-defined, cross-platform protocol, it is even possible to have an X application running on (for example) an OpenBSD machine using a DragonFly BSD machine for its display. The client and server can also be running on the same machine, and for most of this section, that will be the assumption.

Configuring X

X often requires no configuration at all. You can put your configuration files in /usr/local/etc/X11/ or /usr/local/etc/X11/xorg.conf.d/

Read xorg.conf(5) for more information on configuration files.

Add user running X to video group in order to use 3D acceleration.

Starting X

There are two common ways to run X: by manually invoking the startx(1) or via xdm(1).

Note: twm(1) window manager is started by default.

Introduction to X Display Manager

The X Display Manager (XDM) is an optional part of the X Window System that provides services similar to those provided by init(8), getty(8) and login(1) on character terminals: prompting for login name and password, authenticating the user, and running a "session".

Running X Display Manager

Manually run /usr/local/bin/xdm as root or to run the XDM daemon on a virtual terminal change field 4 from off to on in /etc/ttys file:

ttyv8   "/usr/local/bin/xdm -nodaemon"  xterm   off secure

and restart init(8).

Running a Network Display Server

In order for other clients to connect to the display server, edit the access control rules and enable the connection listener. To make XDM listen for connections comment out a line in the /usr/local/etc/X11/xdm/xdm-config file:

! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
DisplayManager.requestPort:     0

and restart xdm(1). More strict access controls may be desired, so look at the example entries in /usr/local/etc/X11/xdm/Xaccess, and refer to the xdm(1) manual page for further information.

Customizing X

When an X session is started, shell scripts in the user's home directory can be used to start as many programs as desired. Most of the programs in these scripts should run in the background, but the last one (typically the window manager) should run in the foreground. When the window manager exits, the script will exit, and X will shut down or return to the xdm(1) login prompt.

The startx(1) command looks for a $HOME/.xinitrc script. If this script doesn't exist, the system's /usr/local/etc/X11/xinit/xinitrc file is used instead.

After the user logs in from xdm(1), the /usr/local/etc/X11/xdm/Xsession script checks whether there is a $HOME/.xsession script.

In the simplest case, your .xinitrc or .xsession script contains only one line specifying your preferred window manager:


Or you can get a little more fancy:

export LANG=en_US.UTF-8
setxkbmap -layout us,ru -option grp:sclk_toggle
xconsole -geometry -0+0 -fn 5x7 &
xclock -geometry 75x75-0-0 &
xsetroot -solid grey &
xterm -geometry 100x25-400+250 &

Note: make sure your .xsession file is executable.