9 This chapter will cover the usual way of giving your Dragonfly BSD system an X Window style Graphical User Interface (GUI).
11 This multi-layered approach may be surprising to people coming from systems like Mac or like Windows where these components are not so flexible, or provided by so many separately installed and configured pieces.
13 Before reading this chapter, you should know how to install additional third-party software. Read the [dports](/docs/howtos/HowToDPorts) section of the documentation. Then install **xorg** meta package or both **xorg-minimal** and **xorg-apps** meta packages instead and **xdm** package (all of them are under `x11` category). Optionally install **cwm** package (it is under `x11-wm` category).
17 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, i.e. X Server does not provide a way to move and resize windows and does not provide decorations like title bar on the top of windows. The X11 specification is an open standard, and there are different implementations, some commercial, and some free. [X.org](https://www.x.org/) is the free implementation of the X11 specification.
19 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.
23 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/
25 Read [xorg.conf(5)](https://leaf.dragonflybsd.org/cgi/web-man?command=xorg.conf§ion=5) for more information on configuration files.
27 Add user running X to video group in order to use 3D acceleration:
29 # pw groupmod video -m username
33 There are two common ways to run X: by manually invoking the [startx(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=startx§ion=1) or via [xdm(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=xdm§ion=1).
35 **Note:** [twm(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=twm§ion=1) window manager is started by default.
37 ### Introduction to X Display Manager
39 The X Display Manager (XDM) is an optional part of the X Window System that provides services similar to those provided by [init(8)](https://leaf.dragonflybsd.org/cgi/web-man?command=init§ion=8), [getty(8)](https://leaf.dragonflybsd.org/cgi/web-man?command=getty§ion=8) and [login(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=login§ion=1) on character terminals: prompting for login name and password, authenticating the user, and running a "session".
41 ### Running X Display Manager
43 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:
45 ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
47 and restart [init(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=init§ion=8).
49 ### Running a Network Display Server
51 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:
53 ! SECURITY: do not listen for XDMCP or Chooser requests
54 ! Comment out this line if you want to manage X terminals with xdm
55 DisplayManager.requestPort: 0
57 and restart [xdm(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=xdm§ion=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)](http://leaf.dragonflybsd.org/cgi/web-man?command=xdm§ion=1) manual page for further information.
61 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)](https://leaf.dragonflybsd.org/cgi/web-man?command=xdm§ion=1) login prompt.
63 The [startx(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=startx§ion=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.
65 After the user logs in from [xdm(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=xdm§ion=1), the /usr/local/etc/X11/xdm/Xsession script checks whether there is a $HOME/.xsession script.
67 In the simplest case, your .xinitrc or .xsession script contains only one line specifying your preferred window manager:
71 Or you can get a little more fancy:
73 export LANG=en_US.UTF-8
74 setxkbmap -layout us,ru -option grp:sclk_toggle
75 xconsole -geometry -0+0 -fn 5x7 &
76 xclock -geometry 75x75-0-0 &
77 xsetroot -solid grey &
78 xterm -geometry 100x25-400+250 &
81 **Note:** make sure you .xsession file is executable:
83 % chmod o+x ~/.xsession