Keep it simple
[ikiwiki.git] / docs / handbook / X / index.mdwn
1 # The X Window System 
2
3 This chapter will cover the usual way of giving your Dragonfly BSD system an X Window style Graphical User Interface (GUI).
4
5 Before reading this chapter, install **xorg**, **xdm** and **cwm** packages.
6
7 ## Introduction to X 
8
9 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](https://www.x.org/) is the free implementation of the X11 specification.
10
11 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.
12
13 ## Configuring X
14
15 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/
16
17 Read [xorg.conf(5)](https://leaf.dragonflybsd.org/cgi/web-man?command=xorg.conf&section=5) for more information on configuration files.
18
19 Add user running X to video group in order to use 3D acceleration:
20
21     # pw groupmod video -m username
22
23 ## Starting X
24
25 There are two common ways to run X: by manually invoking the [startx(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=startx&section=1) or via [xdm(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=xdm&section=1).
26
27 **Note:** [twm(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=twm&section=1) window manager is started by default.
28
29 ### Introduction to X Display Manager
30
31 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&section=8), [getty(8)](https://leaf.dragonflybsd.org/cgi/web-man?command=getty&section=8) and [login(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=login&section=1) on character terminals: prompting for login name and password, authenticating the user, and running a "session".
32
33 ### Running X Display Manager
34
35 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:
36
37     ttyv8   "/usr/local/bin/xdm -nodaemon"  xterm   off secure
38
39 and restart [init(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=init&section=8).
40
41 ### Running a Network Display Server
42
43 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:
44
45     ! SECURITY: do not listen for XDMCP or Chooser requests
46     ! Comment out this line if you want to manage X terminals with xdm
47     DisplayManager.requestPort:     0
48
49 and restart [xdm(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=xdm&section=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&section=1) manual page for further information.
50
51 ## Customizing X
52
53 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&section=1) login prompt.
54
55 The [startx(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=startx&section=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.
56
57 After the user logs in from [xdm(1)](https://leaf.dragonflybsd.org/cgi/web-man?command=xdm&section=1), the /usr/local/etc/X11/xdm/Xsession script checks whether there is a $HOME/.xsession script.
58
59 In the simplest case, your .xinitrc or .xsession script contains only one line specifying your preferred window manager:
60
61     cwm
62
63 Or you can get a little more fancy:
64
65     export LANG=en_US.UTF-8
66     setxkbmap -layout us,ru -option grp:sclk_toggle
67     xconsole -geometry -0+0 -fn 5x7 &
68     xclock -geometry 75x75-0-0 &
69     xsetroot -solid grey &
70     xterm -geometry 100x25-400+250 &
71     cwm
72
73 **Note:** make sure your .xsession file is executable:
74
75     % chmod u+x ~/.xsession