aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/x11/chapter.sgml
blob: 08d4c892953fc38b419deb957e472e86bd173833 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->

<chapter id="x11">
  <chapterinfo>
    <authorgroup>
      <author>
	<firstname>Ken</firstname>
	<surname>Tom</surname>
	<contrib>Updated for X.Org's X11 server by </contrib>
      </author>
      <author>
	<firstname>Marc</firstname>
	<surname>Fonvieille</surname>
      </author>
    </authorgroup>
  </chapterinfo>

  <title>The X Window System</title>

  <sect1 id="x11-synopsis">
    <title>Synopsis</title>

    <para>FreeBSD uses X11 to provide users with
      a powerful graphical user interface.  X11
      is a freely available version of the X Window System that
      is implemented in <application>&xorg;</application>
      (and other software
      packages not discussed here).
      The
      default and official flavor of X11 in &os; is
      <application>&xorg;</application>, the X11 server developed by
      the X.Org Foundation under a license very similar to the one used
      by &os;.  Commercial X servers for &os; are also available.</para>

    <para>For more information on the video hardware that X11
      supports, check the <ulink
      url="http://www.x.org/">&xorg;</ulink> web site.</para>

    <para>After reading this chapter, you will know:</para>

    <itemizedlist>
      <listitem>
	<para>The various components of the X Window System, and how they
	  interoperate.</para>
      </listitem>

      <listitem>
	<para>How to install and configure X11.</para>
      </listitem>

      <listitem>
	<para>How to install and use different window managers.</para>
      </listitem>

      <listitem>
	<para>How to use &truetype; fonts in X11.</para>
      </listitem>

      <listitem>
	<para>How to set up your system for graphical logins
	  (<application>XDM</application>).</para>
      </listitem>
    </itemizedlist>

    <para>Before reading this chapter, you should:</para>

    <itemizedlist>
      <listitem>
	<para>Know how to install additional third-party
	  software (<xref linkend="ports">).</para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 id="x-understanding">
    <title>Understanding X</title>

    <para>Using X for the first time can be somewhat of a shock to someone
      familiar with other graphical environments, such as &microsoft.windows; or
      &macos;.</para>

    <para>While it is not necessary to understand all of the details of various
      X components and how they interact, some basic knowledge makes
      it possible to take advantage of X's strengths.</para>

    <sect2>
      <title>Why X?</title>

      <para>X is not the first window system written for &unix;, but it is the
	most popular of them.  X's original development team had worked on another
	window system prior to writing X.  That system's name was
	<quote>W</quote> (for <quote>Window</quote>).  X was just the next
	letter in the Roman alphabet.</para>

      <para>X can be called <quote>X</quote>, <quote>X Window System</quote>,
	<quote>X11</quote>, and a number of other terms.  You may find
	that using the term <quote>X Windows</quote> to describe X11
	can be offensive to some people; for a bit more insight on
	this, see &man.X.7;.</para>
    </sect2>

    <sect2>
      <title>The X Client/Server Model</title>

      <para>X was designed from the beginning to be network-centric, and
	adopts a <quote>client-server</quote> model.</para>

      <para>In the X model, the
	<quote>X server</quote> runs on the computer that has the keyboard,
	monitor, and mouse attached.  The server's responsibility includes tasks such as managing
	the display, handling input from the keyboard and mouse, and other
	input or output devices (i.e., a <quote>tablet</quote> can be used as
	an input device, and a video projector may be an alternative output
	device).
	Each X application (such as <application>XTerm</application>, or
	<application>&netscape;</application>) is a <quote>client</quote>.  A
	client sends messages to the server such as <quote>Please draw a
	window at these coordinates</quote>, and the server sends back
	messages such as <quote>The user just clicked on the OK
	button</quote>.</para>

      <para>In a home or small
	office environment, the X server and the X clients commonly run on
	the same computer.  However, it is perfectly possible to run the X
	server on a less powerful desktop computer, and run X applications
	(the clients) on, say, the powerful and expensive machine that serves
	the office.  In this scenario the communication between the X client
	and server takes place over the network.</para>

      <para>This confuses some people, because the X terminology is
	exactly backward to what they expect.  They expect the <quote>X
	server</quote> to be the big powerful machine down the hall, and
	the <quote>X client</quote> to be the machine on their desk.</para>

      <para>It is important to remember that the X server is the machine with the monitor and
	keyboard, and the X clients are the programs that display the
	windows.</para>

      <para>There is nothing in the protocol that forces the client and
	server machines to be running the same operating system, or even to
	be running on the same type of computer.  It is certainly possible to
	run an X server on &microsoft.windows; or Apple's &macos;, and there are
	various free and commercial applications available that do exactly
	that.</para>
    </sect2>

    <sect2>
      <title>The Window Manager</title>

      <para>The X design philosophy is much like the &unix; design philosophy,
	<quote>tools, not policy</quote>.  This means that X does not try to
	dictate how a task is to be accomplished.  Instead, tools are provided
	to the user, and it is the user's responsibility to decide how to use
	those tools.</para>

      <para>This philosophy extends to X not dictating what windows should
	look like on screen, how to move them around with the mouse, what
	keystrokes should be used to move between windows (i.e.,
	<keycombo action="simul">
	  <keycap>Alt</keycap>
	  <keycap>Tab</keycap>
	</keycombo>, in the case of &microsoft.windows;), what the title bars
	on each window should look like, whether or not they have close
	buttons on them, and so on.</para>

      <para>Instead, X delegates this responsibility to an application called
	a <quote>Window Manager</quote>.  There are dozens of window
	managers available for X: <application>AfterStep</application>,
	<application>Blackbox</application>, <application>ctwm</application>,
	<application>Enlightenment</application>,
	<application>fvwm</application>, <application>Sawfish</application>,
	<application>twm</application>,
	<application>Window Maker</application>, and more.  Each of these
	window managers provides a different look and feel; some of them
	support <quote>virtual desktops</quote>; some of them allow customized
	keystrokes to manage the desktop; some have a <quote>Start</quote>
	button or similar device; some are <quote>themeable</quote>, allowing
	a complete change of look-and-feel by applying a new theme.  These
	window managers, and many more, are available in the
	<filename>x11-wm</filename> category of the Ports Collection.</para>

      <para>In addition, the <application>KDE</application> and
	<application>GNOME</application> desktop environments both have their
	own window managers which integrate with the desktop.</para>

      <para>Each window manager also has a different configuration mechanism;
	some expect configuration file written by hand, others feature
	GUI tools for most of the configuration tasks; at least one
	(<application>Sawfish</application>) has a configuration file written
	in a dialect of the Lisp language.</para>

      <note>
	<title>Focus Policy</title>

	<para>Another feature the window manager is responsible for is the
	  mouse <quote>focus policy</quote>.  Every windowing system
	  needs some means of choosing a window to be actively receiving
	  keystrokes, and should visibly indicate which window is active as
	  well.</para>

	<para>A familiar focus policy is called <quote>click-to-focus</quote>.
	  This is the model utilized by &microsoft.windows;, in which a window
	  becomes active upon receiving a mouse click.</para>

	<para>X does not support any particular focus policy.  Instead, the
	  window manager controls which window has the focus at any one time.
	  Different window managers will support different focus methods.  All
	  of them support click to focus, and the majority of them support
	  several others.</para>

	<para>The most popular focus policies are:</para>

	<variablelist>
	  <varlistentry>
	    <term>focus-follows-mouse</term>

	    <listitem>
	      <para>The window that is under the mouse pointer is the
		window that has the focus.  This may not necessarily be
		the window that is on top of all the other windows.
		The focus is changed by pointing at another window, there
		is no need to click in it as well.</para>
	    </listitem>
	  </varlistentry>

	  <varlistentry>
	    <term>sloppy-focus</term>

	    <listitem>
	      <para>This policy is a small extension to focus-follows-mouse.
		With focus-follows-mouse, if the mouse is moved over the
		root window (or background) then no window has the focus,
		and keystrokes are simply lost.  With sloppy-focus, focus is
		only changed when the cursor enters a new window, and not
		when exiting the current window.</para>
	    </listitem>
	  </varlistentry>

	  <varlistentry>
	    <term>click-to-focus</term>

	    <listitem>
	      <para>The active window is selected by mouse click.  The
		window may then be <quote>raised</quote>, and appear in
		front of all other windows.  All keystrokes will now be
		directed to this window, even if the cursor is moved to
		another window.</para>
	    </listitem>
	  </varlistentry>
	</variablelist>

	<para>Many window managers support other policies, as well as
	  variations on these.  Be sure to consult the documentation for
	  the window manager itself.</para>
      </note>
    </sect2>

    <sect2>
      <title>Widgets</title>

      <para>The X approach of providing tools and not policy extends to the
	widgets seen on screen in each application.</para>

      <para><quote>Widget</quote> is a term for all the items in the user
	interface that can be clicked or manipulated in some way; buttons,
	check boxes, radio buttons, icons, lists, and so on.  &microsoft.windows;
	calls these <quote>controls</quote>.</para>

      <para>&microsoft.windows; and Apple's &macos; both have a very rigid widget
	policy.  Application developers are supposed to ensure that their
	applications share a common look and feel.  With X, it was not
	considered sensible to mandate a particular graphical style, or set
	of widgets to adhere to.</para>

      <para>As a result, do not expect X applications to have a common
	look and feel.  There are several popular widget sets and
	variations, including the original Athena widget set from MIT,
	<application>&motif;</application> (on which the widget set in
	&microsoft.windows; was modeled, all bevelled edges and three shades of
	grey), <application>OpenLook</application>, and others.</para>

      <para>Most newer X applications today will use a modern-looking widget
	set, either Qt, used by <application>KDE</application>, or
	GTK+, used by the
	<application>GNOME</application>
	project.  In this respect, there is some convergence in
	look-and-feel of the &unix; desktop, which certainly makes things
	easier for the novice user.</para>
    </sect2>
  </sect1>

  <sect1 id="x-install">
    <title>Installing X11</title>

    <para><application>&xorg;</application> is the default X11
      implementation for &os;.  <application>&xorg;</application> is
      the X server of the open source X Window System implementation released by the X.Org
      Foundation.  <application>&xorg;</application> is based on the code of
      <application>&xfree86&nbsp;4.4RC2</application> and X11R6.6.
      The version of <application>&xorg;</application> currently
      available in the &os; Ports Collection is &xorg.version;.</para>

    <para>To build and install <application>&xorg;</application> from the
      Ports Collection:</para>

    <screen>&prompt.root; <userinput>cd /usr/ports/x11/xorg</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>

    <note>
      <para>To build <application>&xorg;</application> in its
	entirety, be sure to have at least 4&nbsp;GB of free space
	available.</para>
    </note>

    <para>Alternatively, X11
      can be installed directly from packages.
      Binary packages to use with &man.pkg.add.1; tool are also available for
      X11.  When the remote fetching
      feature of &man.pkg.add.1; is used, the version number of the
      package must be removed.  &man.pkg.add.1; will automatically fetch
      the latest version of the application.</para>

    <para>So to fetch and install the package of
      <application>&xorg;</application>, simply type:</para>

    <screen>&prompt.root; <userinput>pkg_add -r xorg</userinput></screen>

    <note><para>The examples above will install the complete
      X11 distribution including the
      servers, clients, fonts etc.  Separate packages and ports of X11
      are also
      available.</para>

    <para>To install a minimal X11 distribution you can alternatively install
      <filename role="package">x11/xorg-minimal</filename>.</para>
    </note>

    <para>The rest of this chapter will explain how to configure
      X11, and how to set up a productive desktop
      environment.</para>
  </sect1>

  <sect1 id="x-config">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Christopher</firstname>
	  <surname>Shumway</surname>
	  <contrib>Contributed by </contrib>
	  <!-- July 2001 -->
	</author>
      </authorgroup>
    </sect1info>
    <title>X11 Configuration</title>


    <indexterm><primary>&xorg;</primary></indexterm>
    <indexterm><primary>X11</primary></indexterm>

    <sect2>
      <title>Before Starting</title>

      <para>Before configuration of X11
	the following information about the target system is needed:</para>

      <itemizedlist>
	<listitem><para>Monitor specifications</para></listitem>
	<listitem><para>Video Adapter chipset</para></listitem>
	<listitem><para>Video Adapter memory</para></listitem>
      </itemizedlist>

      <indexterm><primary>horizontal scan rate</primary></indexterm>
      <indexterm><primary>vertical scan rate</primary></indexterm>

      <para>The specifications for the monitor are used by
	X11 to determine the resolution and
	refresh rate to run at.  These specifications can usually be
	obtained from the documentation that came with the monitor or from
	the manufacturer's website.  There are two ranges of numbers that
	are needed, the horizontal scan rate and the vertical synchronization
	rate.</para>

      <para>The video adapter's chipset defines what driver module
	X11 uses to talk to the graphics
	hardware.  With most chipsets, this can be automatically
	determined, but it is still useful to know in case the automatic
	detection does not work correctly.</para>

      <para>Video memory on the graphic adapter determines the
	resolution and color depth which the system can run at.  This is
	important to know so the user knows the limitations of the
	system.</para>
    </sect2>

    <sect2>
      <title>Configuring X11</title>

      <para><application>&xorg;</application>
	uses <acronym>HAL</acronym> to autodetect keyboards and mice.
	The <filename role="package">sysutils/hal</filename> and
	<filename role="package">devel/dbus</filename> ports are installed
	as dependencies of <filename role="package">x11/xorg</filename>, but
	must be enabled by the following entries in the
	<filename>/etc/rc.conf</filename> file:</para>

      <programlisting>hald_enable="YES"
dbus_enable="YES"</programlisting>

      <para>These services should be started (either manually or by
	rebooting) before further <application>&xorg;</application>
	configuration or use is attempted.</para>

      <para><application>&xorg;</application> can
	often work without any further configuration steps by simply typing at
	prompt:</para>

      <screen>&prompt.user; <userinput>startx</userinput></screen>

      <para>The automatic configuration may fail to work with some hardware,
	or may not set things up quite as desired.  In these cases, manual
	configuration will be necessary.</para>

      <note>
	<para>Desktop environments like
	  <application>GNOME</application>,
	  <application>KDE</application> or
	  <application>Xfce</application> have tools allowing the user
	  to easily set the screen parameters such as the resolution.
	  So if the default configuration is not acceptable and you
	  planned to install a desktop environment then just continue
	  with the installation of the desktop environment and use the
	  appropriate screen settings tool.</para>
      </note>

      <para>Configuration of X11 is
	a multi-step process.  The first step is to build an initial
	configuration file.
	As the super user, simply
	run:</para>

      <screen>&prompt.root; <userinput>Xorg -configure</userinput></screen>

      <para>This will generate an
	X11 configuration skeleton file in the
	<filename>/root</filename> directory called
	<filename>xorg.conf.new</filename> (whether you &man.su.1; or
	do a direct login affects the inherited supervisor
	<envar>$HOME</envar> directory variable).  The
	X11 program will attempt to probe
	the graphics hardware on the system and write a
	configuration file to load the proper drivers for the detected
	hardware on the target system.</para>

      <para>The next step is to test the existing
	configuration to verify that <application>&xorg;</application>
	can work with the graphics
	hardware on the target system.  Type:</para>

      <screen>&prompt.root; <userinput>Xorg -config xorg.conf.new -retro</userinput></screen>

      <para>If a black and grey grid and an X mouse cursor appear,
	the configuration was successful.  To exit the test, switch to the
	virtual console used to start it by pressing
	<keycombo action="simul">
	  <keycap>Ctrl</keycap>
	  <keycap>Alt</keycap>
	  <keycap>F<replaceable>n</replaceable></keycap>
	</keycombo> (<keycap>F1</keycap> for the first virtual console)
	and press
	<keycombo action="simul">
	  <keycap>Ctrl</keycap>
	  <keycap>C</keycap>
	</keycombo>.</para>

      <note>
	<para>The
	  <keycombo action="simul">
	    <keycap>Ctrl</keycap>
	    <keycap>Alt</keycap>
	    <keycap>Backspace</keycap>
	  </keycombo> key combination may also be used to break out of
	  <application>&xorg;</application>.  To enable it,
	  you can either type the following
	  command from any X terminal emulator:</para>

	<screen>&prompt.user; <userinput>setxkbmap -option terminate:ctrl_alt_bksp</userinput></screen>

	<para>or create a keyboard configuration file for
	  <application>hald</application> called
	  <filename>x11-input.fdi</filename> and saved in the
	  <filename
	  class="directory">/usr/local/etc/hal/fdi/policy</filename>
	  directory.  This file should contain the following
	  lines:</para>

	<programlisting>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;deviceinfo version="0.2"&gt;
  &lt;device&gt;
    &lt;match key="info.capabilities" contains="input.keyboard"&gt;
	  &lt;merge key="input.x11_options.XkbOptions" type="string"&gt;terminate:ctrl_alt_bksp&lt;/merge&gt;
    &lt;/match&gt;
  &lt;/device&gt;
&lt;/deviceinfo&gt;</programlisting>

	<para>You will have to reboot your machine to force
	  <application>hald</application> to read this file.</para>

	<para>The following line will also have to be added to
	  <filename>xorg.conf.new</filename>, in the
	  <literal>ServerLayout</literal> or <literal>ServerFlags</literal>
	  section:</para>

	<programlisting>Option	"DontZap"	"off"</programlisting>
      </note>

	<para>If the mouse does not work, you will need to first
	  configure it before proceeding.  See <xref linkend="mouse">
	  in the &os; install chapter.  In recent
	  <application>Xorg</application> versions,
	  the <literal>InputDevice</literal> sections in
	  <filename>xorg.conf</filename> are ignored in favor of the
	  autodetected devices.  To restore the old behavior, add the
	  following line to the <literal>ServerLayout</literal> or
	  <literal>ServerFlags</literal> section of this file:</para>

	  <programlisting>Option "AutoAddDevices" "false"</programlisting>

	  <para>Input devices may then be configured as in previous versions,
	    along with any other options needed (e.g., keyboard layout
	    switching).</para>

      <note>
	<para>As previously explained
	  the <application>hald</application> daemon will, by default,
	  automatically detect your keyboard.  There are chances that
	  your keyboard layout or model will not be correct, desktop
	  environments like <application>GNOME</application>,
	  <application>KDE</application> or
	  <application>Xfce</application> provide tools to configure
	  the keyboard.  However, it is possible to set the keyboard
	  properties directly either with the help of the
	  &man.setxkbmap.1; utility or with a
	  <application>hald</application>'s configuration rule.</para>

	<para>For example if one wants to use a PC 102 keys keyboard
	  coming with a french layout, we have to create a keyboard
	  configuration file for <application>hald</application>
	  called <filename>x11-input.fdi</filename> and saved in the
	  <filename
	  class="directory">/usr/local/etc/hal/fdi/policy</filename>
	  directory.  This file should contain the following
	  lines:</para>

	<programlisting>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;deviceinfo version="0.2"&gt;
  &lt;device&gt;
    &lt;match key="info.capabilities" contains="input.keyboard"&gt;
	  &lt;merge key="input.x11_options.XkbModel" type="string"&gt;pc102&lt;/merge&gt;
	  &lt;merge key="input.x11_options.XkbLayout" type="string"&gt;fr&lt;/merge&gt;
    &lt;/match&gt;
  &lt;/device&gt;
&lt;/deviceinfo&gt;</programlisting>

	<para>If this file already exists, just copy and add to your
	  file the lines regarding the keyboard configuration.</para>

	<para>You will have to reboot your machine to force
	  <application>hald</application> to read this file.</para>

	<para>It is possible to do the same configuration from an X
	  terminal or a script with this command line:</para>

	<screen>&prompt.user; <userinput>setxkbmap -model pc102 -layout fr</userinput></screen>

	<para>The
	  <filename>/usr/local/share/X11/xkb/rules/base.lst</filename>
	  file lists the various keyboard, layouts and options
	  available.</para>
      </note>

      <indexterm><primary>X11 tuning</primary></indexterm>

      <para>Next, tune the <filename>xorg.conf.new</filename>
	configuration file to taste.  Open the file in a text editor such
	as &man.emacs.1; or &man.ee.1;.  First, add the
	frequencies for the target system's monitor.  These are usually
	expressed as a horizontal and vertical synchronization rate.  These
	values are added to the <filename>xorg.conf.new</filename> file
	under the <literal>"Monitor"</literal> section:</para>

      <programlisting>Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
	HorizSync    30-107
	VertRefresh  48-120
EndSection</programlisting>

      <para>The <literal>HorizSync</literal> and
	<literal>VertRefresh</literal> keywords may be missing in the
	configuration file.  If they are, they need to be added, with
	the correct horizontal synchronization rate placed after the
	<literal>HorizSync</literal> keyword and the vertical
	synchronization rate after the <literal>VertRefresh</literal>
	keyword.  In the example above the target monitor's rates were
	entered.</para>

      <para>X allows DPMS (Energy Star) features to be used with capable
	monitors. The &man.xset.1; program controls the time-outs and can force
	standby, suspend, or off modes.  If you wish to enable DPMS features
	for your monitor, you must add the following line to the monitor
	section:</para>

      <programlisting>
	Option       "DPMS"</programlisting>

      <indexterm>
	<primary><filename>xorg.conf</filename></primary>
      </indexterm>

      <para>While the <filename>xorg.conf.new</filename>
	configuration file is still open in an editor, select
	the default resolution and color depth desired.  This is
	defined in the <literal>"Screen"</literal> section:</para>

      <programlisting>Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	DefaultDepth 24
	SubSection "Display"
		Viewport  0 0
		Depth     24
		Modes     "1024x768"
	EndSubSection
EndSection</programlisting>

      <para>The <literal>DefaultDepth</literal> keyword describes
	the color depth to run at by default.  This can be overridden
	with the <option>-depth</option> command line switch to
	&man.Xorg.1;.
	The <literal>Modes</literal> keyword
	describes the resolution to run at for the given color depth.
	Note that only VESA standard modes are supported as defined by
	the target system's graphics hardware.
	In the example above, the default color depth is twenty-four
	bits per pixel.  At this color depth, the accepted resolution is
	1024 by 768
	pixels.</para>

      <para>Finally, write the configuration file and test it using
	the test mode given above.</para>

      <note>
	<para>One of the tools available to assist you during
	  troubleshooting process are the X11 log files, which contain
	  information on each device that the X11 server attaches to.
	  <application>&xorg;</application> log file names are in the format
	  of <filename>/var/log/Xorg.0.log</filename>.  The exact name
	  of the log can vary from <filename>Xorg.0.log</filename> to
	  <filename>Xorg.8.log</filename> and so forth.</para>
      </note>

      <para>If all is well, the configuration
	file needs to be installed in a common location where
	&man.Xorg.1; can find it.
	This is typically <filename>/etc/X11/xorg.conf</filename> or
	<filename>/usr/local/etc/X11/xorg.conf</filename>.</para>

      <screen>&prompt.root; <userinput>cp xorg.conf.new /etc/X11/xorg.conf</userinput></screen>

      <para>The X11 configuration process is now
	complete.  <application>&xorg;</application> may be now
	started with the &man.startx.1; utility.
	The X11 server may also be started with the use of
	&man.xdm.1;.</para>
    </sect2>

    <sect2>
      <title>Advanced Configuration Topics</title>

      <sect3>
	<title>Configuration with &intel; i810 Graphics Chipsets</title>

	<indexterm><primary>Intel i810 graphic chipset</primary></indexterm>

	<para>Configuration with &intel; i810 integrated chipsets
	  requires the <devicename>agpgart</devicename>
	  AGP programming interface for X11
	  to drive the card.  See the &man.agp.4; driver manual page
	  for more information.</para>

	<para>This will allow configuration of the hardware as any other
	  graphics board.  Note on systems without the &man.agp.4;
	  driver compiled in the kernel, trying to load the module
	  with &man.kldload.8; will not work.  This driver has to be
	  in the kernel at boot time through being compiled in or
	  using <filename>/boot/loader.conf</filename>.</para>
      </sect3>

      <sect3>
	<title>Adding a Widescreen Flatpanel to the Mix</title>

	<indexterm><primary>widescreen flatpanel configuration</primary></indexterm>

	<para>This section assumes a bit of advanced configuration knowledge.
	  If attempts to use the standard configuration tools above have not
	  resulted in a working configuration, there is information enough
	  in the log files to be of use in getting the setup working.
	  Use of a text editor will be necessary.</para>

	<para>Current widescreen (WSXGA, WSXGA+, WUXGA, WXGA, WXGA+, et.al.)
	  formats support 16:10 and 10:9 formats or aspect ratios that can
	  be problematic.  Examples of some common screen resolutions for
	  16:10 aspect ratios are:</para>

	<itemizedlist>
	  <listitem><para>2560x1600</para></listitem>
	  <listitem><para>1920x1200</para></listitem>
	  <listitem><para>1680x1050</para></listitem>
	  <listitem><para>1440x900</para></listitem>
	  <listitem><para>1280x800</para></listitem>
	</itemizedlist>

	<para>At some point, it will be as easy as adding one of these
	  resolutions as a possible <literal>Mode</literal> in the <literal>Section
	  "Screen"</literal> as such:</para>

	<programlisting>Section "Screen"
Identifier "Screen0"
Device     "Card0"
Monitor    "Monitor0"
DefaultDepth 24
SubSection "Display"
	Viewport  0 0
	Depth     24
	Modes     "1680x1050"
EndSubSection
EndSection</programlisting>

	<para><application>&xorg;</application> is smart enough to pull the
	  resolution information from  the widescreen via I2C/DDC information
	  so it knows what the monitor can handle as far as frequencies
	  and resolutions.</para>

	<para>If those <literal>ModeLines</literal> do not exist in the drivers,
	  one might need to give <application>&xorg;</application> a little hint.
	  Using <filename>/var/log/Xorg.0.log</filename> one can extract
	  enough information to manually create a <literal>ModeLine</literal> that
	  will work.  Simply look for information resembling this:</para>

	<programlisting>(II) MGA(0): Supported additional Video Mode:
(II) MGA(0): clock: 146.2 MHz   Image Size:  433 x 271 mm
(II) MGA(0): h_active: 1680  h_sync: 1784  h_sync_end 1960 h_blank_end 2240 h_border: 0
(II) MGA(0): v_active: 1050  v_sync: 1053  v_sync_end 1059 v_blanking: 1089 v_border: 0
(II) MGA(0): Ranges: V min: 48  V max: 85 Hz, H min: 30  H max: 94 kHz, PixClock max 170 MHz</programlisting>

	<para>This information is called EDID information.  Creating a
	  <literal>ModeLine</literal> from this is just a matter of putting the
	  numbers in the correct order:</para>

	<programlisting>ModeLine &lt;name&gt; &lt;clock&gt; &lt;4 horiz. timings&gt; &lt;4 vert. timings&gt;</programlisting>

	<para>So that the <literal>ModeLine</literal> in <literal>Section "Monitor"</literal>
	  for this example would look like this:</para>

	<programlisting>Section "Monitor"
Identifier      "Monitor1"
VendorName      "Bigname"
ModelName       "BestModel"
ModeLine        "1680x1050" 146.2 1680 1784 1960 2240 1050 1053 1059 1089
Option          "DPMS"
EndSection</programlisting>

	<para>Now having completed these simple editing steps, X should start
	  on your new widescreen monitor.</para>
      </sect3>
    </sect2>
  </sect1>

  <sect1 id="x-fonts">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Murray</firstname>
	  <surname>Stokely</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
    </sect1info>
    <title>Using Fonts in X11</title>

    <sect2 id="type1">
    <title>Type1 Fonts</title>
    <para>The default fonts that ship with
      X11 are less than ideal for typical
    desktop publishing applications.  Large presentation fonts show up
    jagged and unprofessional looking, and small fonts in
    <application>&netscape;</application> are almost completely unintelligible.
    However, there are several free, high quality Type1 (&postscript;) fonts
    available which can be readily used
    with X11.  For instance, the URW font collection
    (<filename role="package">x11-fonts/urwfonts</filename>) includes
    high quality versions of standard type1 fonts (<trademark class="registered">Times Roman</trademark>,
    <trademark class="registered">Helvetica</trademark>, <trademark class="registered">Palatino</trademark> and others).  The Freefonts collection
    (<filename role="package">x11-fonts/freefonts</filename>) includes
    many more fonts, but most of them are intended for use in
    graphics software such as the <application>Gimp</application>, and are not
    complete enough to serve as screen fonts.  In addition,
    X11 can be configured to use
    &truetype; fonts with a minimum of effort.  For more details on
    this, see the &man.X.7; manual page or the
    <link linkend="truetype">section on &truetype; fonts</link>.</para>

    <para>To install the above Type1 font collections from the
      Ports Collection, run the following commands:</para>

    <screen>&prompt.root; <userinput>cd /usr/ports/x11-fonts/urwfonts</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>

    <para>And likewise with the freefont or other collections.  To have the X
      server detect these fonts, add an appropriate line to the
      X server configuration file (<filename>/etc/X11/xorg.conf</filename>),
      which reads:</para>

      <programlisting>FontPath "/usr/local/lib/X11/fonts/URW/"</programlisting>

      <para>Alternatively, at the command line in the X session
	run:</para>

      <screen>&prompt.user; <userinput>xset fp+ /usr/local/lib/X11/fonts/URW</userinput>
&prompt.user; <userinput>xset fp rehash</userinput></screen>

      <para>This will work but will be lost when the X session is closed,
    unless it is added to the startup file (<filename>~/.xinitrc</filename>
    for a normal <command>startx</command> session,
    or <filename>~/.xsession</filename> when logging in through a
    graphical login manager like <application>XDM</application>).
    A third way is to use the new
    <filename>/usr/local/etc/fonts/local.conf</filename> file: see the
    section on <link linkend="antialias">anti-aliasing</link>.</para>
    </sect2>

    <sect2 id="truetype">
    <title>&truetype; Fonts</title>

    <indexterm><primary>TrueType Fonts</primary></indexterm>
    <indexterm><primary>fonts</primary>
      <secondary>TrueType</secondary>
    </indexterm>

    <para><application>&xorg;</application> has built in support
    for rendering &truetype; fonts.  There are two different modules
    that can enable this functionality.  The freetype module is used
    in this example because it is more consistent with the other font
    rendering back-ends.  To enable the freetype module just add the
    following line to the <literal>"Module"</literal> section of the
    <filename>/etc/X11/xorg.conf</filename> file.</para>

    <programlisting>Load  "freetype"</programlisting>

    <para>Now make a directory for the &truetype; fonts (for example,
      <filename>/usr/local/lib/X11/fonts/TrueType</filename>)
      and copy all of the &truetype; fonts into this directory.  Keep in
      mind that &truetype; fonts cannot be directly taken from a
      &macintosh;; they must be in &unix;/&ms-dos;/&windows; format for use by
      X11.  Once the files have been
      copied into this directory, use
      <application>ttmkfdir</application> to create a
      <filename>fonts.dir</filename> file, so that the X font renderer
      knows that these new files have been installed.
      <command>ttmkfdir</command> is available from the FreeBSD
      Ports Collection as
      <filename role="package">x11-fonts/ttmkfdir</filename>.</para>

    <screen>&prompt.root; <userinput>cd /usr/local/lib/X11/fonts/TrueType</userinput>
&prompt.root; <userinput>ttmkfdir -o fonts.dir</userinput></screen>

    <para>Now add the &truetype; directory to the font
      path.  This is just the same as described above for <link
      linkend="type1">Type1</link> fonts, that is, use</para>

    <screen>&prompt.user; <userinput>xset fp+ /usr/local/lib/X11/fonts/TrueType</userinput>
&prompt.user; <userinput>xset fp rehash</userinput></screen>

    <para>or add a <literal>FontPath</literal> line to the
       <filename>xorg.conf</filename> file.</para>

      <para>That's it.  Now <application>&netscape;</application>,
	<application>Gimp</application>,
	<application>&staroffice;</application>, and all of the other X
	applications should now recognize the installed &truetype;
	fonts.  Extremely small fonts (as with text in a high resolution
	display on a web page) and extremely large fonts (within
	<application>&staroffice;</application>) will look much better
	now.</para>
    </sect2>

    <sect2 id="antialias">
    <sect2info>
      <authorgroup>
	<author>
	  <firstname>Joe Marcus</firstname>
	  <surname>Clarke</surname>
	  <contrib>Updated by </contrib>
	  <!-- May 2003 -->
	</author>
      </authorgroup>
    </sect2info>
    <title>Anti-Aliased Fonts</title>

    <indexterm><primary>anti-aliased fonts</primary></indexterm>
    <indexterm><primary>fonts</primary>
      <secondary>anti-aliased</secondary></indexterm>

    <para>All fonts in X11 that are found
      in <filename>/usr/local/lib/X11/fonts/</filename> and
      <filename>~/.fonts/</filename> are automatically 
      made available for anti-aliasing to Xft-aware applications.
      Most recent applications are Xft-aware, including
      <application>KDE</application>, <application>GNOME</application>, and
      <application>Firefox</application>.</para>

    <para>In order to control which fonts are anti-aliased, or to
      configure anti-aliasing properties, create (or edit, if it
      already exists) the file
      <filename>/usr/local/etc/fonts/local.conf</filename>.  Several
      advanced features of the Xft font system can be tuned using
      this file; this section describes only some simple
      possibilities.  For more details, please see
      &man.fonts-conf.5;.</para>

    <indexterm><primary>XML</primary></indexterm>

    <para>This file must be in XML format.  Pay careful attention to
      case, and make sure all tags are properly closed.  The file
      begins with the usual XML header followed by a DOCTYPE
      definition, and then the <literal>&lt;fontconfig&gt;</literal> tag:</para>

    <programlisting>
      &lt;?xml version="1.0"?&gt;
      &lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
      &lt;fontconfig&gt;
    </programlisting>

    <para>As previously stated, all fonts in
      <filename>/usr/local/lib/X11/fonts/</filename> as well as
      <filename>~/.fonts/</filename> are already made available to
      Xft-aware applications.  If you wish to add another directory
      outside of these two directory trees, add a line similar to the
      following to
      <filename>/usr/local/etc/fonts/local.conf</filename>:</para>

    <programlisting>&lt;dir&gt;/path/to/my/fonts&lt;/dir&gt;</programlisting>

    <para>After adding new fonts, and especially new font directories,
      you should run the following command to rebuild the font
      caches:</para>

    <screen>&prompt.root; <userinput>fc-cache -f</userinput></screen>

    <para>Anti-aliasing makes borders slightly fuzzy, which makes very
      small text more readable and removes <quote>staircases</quote> from
      large text, but can cause eyestrain if applied to normal text.  To
      exclude font sizes smaller than 14 point from anti-aliasing, include
      these lines:</para>

      <programlisting>        &lt;match target="font"&gt;
	    &lt;test name="size" compare="less"&gt;
		&lt;double&gt;14&lt;/double&gt;
	    &lt;/test&gt;
	    &lt;edit name="antialias" mode="assign"&gt;
		&lt;bool&gt;false&lt;/bool&gt;
	    &lt;/edit&gt;
	&lt;/match&gt;
	&lt;match target="font"&gt;
	    &lt;test name="pixelsize" compare="less" qual="any"&gt;
		&lt;double&gt;14&lt;/double&gt;
	    &lt;/test&gt;
	    &lt;edit mode="assign" name="antialias"&gt;
		&lt;bool&gt;false&lt;/bool&gt;
	    &lt;/edit&gt;
	&lt;/match&gt;</programlisting>

    <indexterm><primary>fonts</primary>
      <secondary>spacing</secondary></indexterm>

    <para>Spacing for some monospaced fonts may also be inappropriate
      with anti-aliasing.  This seems to be an issue with
      <application>KDE</application>, in particular.  One possible fix for
      this is to force the spacing for such fonts to be 100.  Add the
      following lines:</para>

     <programlisting>       &lt;match target="pattern" name="family"&gt;
	   &lt;test qual="any" name="family"&gt;
	       &lt;string&gt;fixed&lt;/string&gt;
	   &lt;/test&gt;
	   &lt;edit name="family" mode="assign"&gt;
	       &lt;string&gt;mono&lt;/string&gt;
	   &lt;/edit&gt;
	&lt;/match&gt;
	&lt;match target="pattern" name="family"&gt;
	    &lt;test qual="any" name="family"&gt;
		&lt;string&gt;console&lt;/string&gt;
	    &lt;/test&gt;
	    &lt;edit name="family" mode="assign"&gt;
		&lt;string&gt;mono&lt;/string&gt;
	    &lt;/edit&gt;
	&lt;/match&gt;</programlisting>

      <para>(this aliases the other common names for fixed fonts as
	<literal>"mono"</literal>), and then add:</para>

      <programlisting>         &lt;match target="pattern" name="family"&gt;
	     &lt;test qual="any" name="family"&gt;
		 &lt;string&gt;mono&lt;/string&gt;
	     &lt;/test&gt;
	     &lt;edit name="spacing" mode="assign"&gt;
		 &lt;int&gt;100&lt;/int&gt;
	     &lt;/edit&gt;
	 &lt;/match&gt;      </programlisting>

      <para>Certain fonts, such as Helvetica, may have a problem when
	anti-aliased.  Usually this manifests itself as a font that
	seems cut in half vertically.  At worst, it may cause
	applications to
	crash.  To avoid this, consider adding the following to
	<filename>local.conf</filename>:</para>

      <programlisting>         &lt;match target="pattern" name="family"&gt;
	     &lt;test qual="any" name="family"&gt;
		 &lt;string&gt;Helvetica&lt;/string&gt;
	     &lt;/test&gt;
	     &lt;edit name="family" mode="assign"&gt;
		 &lt;string&gt;sans-serif&lt;/string&gt;
	     &lt;/edit&gt;
	 &lt;/match&gt;        </programlisting>

      <para>Once you have finished editing
	<filename>local.conf</filename> make sure you end the file
	with the <literal>&lt;/fontconfig&gt;</literal> tag.  Not doing this will cause
	your changes to be ignored.</para>

       <para>Finally, users can add their own settings via their personal 
	<filename>.fonts.conf</filename> files.  To do this, each user should 
	simply create a <filename>~/.fonts.conf</filename>.  This file must 
	also be in XML format.</para>

       <indexterm><primary>LCD screen</primary></indexterm>
       <indexterm><primary>Fonts</primary>
	 <secondary>LCD screen</secondary></indexterm>

       <para>One last point: with an LCD screen, sub-pixel sampling may be
	desired.  This basically treats the (horizontally separated)
	red, green and blue components separately to improve the horizontal
	resolution; the results can be dramatic.  To enable this, add the
	line somewhere in the <filename>local.conf</filename> file:</para>

	<programlisting>
	  &lt;match target="font"&gt;
	     &lt;test qual="all" name="rgba"&gt;
		 &lt;const&gt;unknown&lt;/const&gt;
	     &lt;/test&gt;
	     &lt;edit name="rgba" mode="assign"&gt;
		 &lt;const&gt;rgb&lt;/const&gt;
	     &lt;/edit&gt;
	 &lt;/match&gt;
       </programlisting>

	<note>
	<para>Depending on the sort of display,
	  <literal>rgb</literal> may need to be changed to <literal>bgr</literal>,
	  <literal>vrgb</literal> or <literal>vbgr</literal>: experiment and
	  see which works best.</para>
	</note>
    </sect2>
  </sect1>

  <sect1 id="x-xdm">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Seth</firstname>
	  <surname>Kingsley</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
    </sect1info>
    <title>The X Display Manager</title>
    <sect2>
      <title>Overview</title>

      <indexterm><primary>X Display Manager</primary></indexterm>
      <para>The X Display Manager (<application>XDM</application>) is
	an optional part of the X Window System that is used for login
	session management.  This is useful for several types of
	situations, including minimal <quote>X Terminals</quote>,
	desktops, and large network display
	servers.  Since the X Window System is network and protocol
	independent, there are a wide variety of possible configurations
	for running X clients and servers on different machines
	connected by a network.  <application>XDM</application> provides
	a graphical interface for choosing which display server to
	connect to, and entering authorization information such as a
	login and password combination.</para>

      <para>Think of <application>XDM</application> as
	providing the same functionality to the user as the
	&man.getty.8; utility (see <xref linkend="term-config"> for
	  details).  That is, it performs system logins to the display
	  being connected to and then runs a session manager on behalf of
	  the user (usually an X window
	  manager).  <application>XDM</application> then waits for this
	  program to exit, signaling that the user is done and should be
	  logged out of the display.  At this point,
	  <application>XDM</application> can display the login and display
	  chooser screens for the next user to login.</para>
    </sect2>

    <sect2>
      <title>Using XDM</title>

      <para>To start using <application>XDM</application>, install the
	<filename role="package">x11/xdm</filename> port (it is not
	installed by default in recent versions of
	<application>&xorg;</application>).
	The <application>XDM</application> daemon program may then be
	found in <filename>/usr/local/bin/xdm</filename>.  This program
	can be run at any time as <username>root</username> and it will
	start managing the X display on the local machine.  If
	<application>XDM</application> is to be run every
	time the machine boots up, a convenient way to do this is by
	adding an entry to <filename>/etc/ttys</filename>.  For more
	information about the format and usage of this file, see <xref
	linkend="term-etcttys">.  There is a line in the default
	<filename>/etc/ttys</filename> file for running the
	<application>XDM</application> daemon on a virtual terminal:</para>

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

      <para>By default this entry is disabled; in order to enable it
	change field 5 from <literal>off</literal> to
	<literal>on</literal> and restart &man.init.8; using the
	directions in <xref linkend="term-hup">.  The first field, the
	name of the terminal this program will manage, is
	<literal>ttyv8</literal>.  This means that
	<application>XDM</application> will start running on the 9th
	virtual terminal.</para>
    </sect2>

    <sect2>
      <title>Configuring XDM</title>

      <para>The <application>XDM</application> configuration directory
	is located in <filename>/usr/local/lib/X11/xdm</filename>.  In
	this directory there are several files used to change the
	behavior and appearance of
	<application>XDM</application>.  Typically these files will
	be found:</para>

	<informaltable frame="none" pgwide="1">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>File</entry>
		<entry>Description</entry>
	      </row>
	    </thead>

	    <tbody>
	      <row>
		<entry><filename>Xaccess</filename></entry>
		<entry>Client authorization ruleset.</entry>
	      </row>

	      <row>
		<entry><filename>Xresources</filename></entry>
		<entry>Default X resource values.</entry>
	      </row>

	      <row>
		<entry><filename>Xservers</filename></entry>
		<entry>List of remote and local displays to manage.</entry>
	      </row>

	      <row>
		<entry><filename>Xsession</filename></entry>
		<entry>Default session script for logins.</entry>
	      </row>

	      <row>
		<entry><filename>Xsetup_</filename>*</entry>
		<entry>Script to launch applications before the login
		  interface.</entry>
	      </row>

	      <row>
		<entry><filename>xdm-config</filename></entry>
		<entry>Global configuration for all displays running on
		  this machine.</entry>
	      </row>

	      <row>
		<entry><filename>xdm-errors</filename></entry>
		<entry>Errors generated by the server program.</entry>
	      </row>

	      <row>
		<entry><filename>xdm-pid</filename></entry>
		<entry>The process ID of the currently running XDM.</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

      <para>Also in this directory are a few scripts and programs used
	to set up the desktop when <application>XDM</application> is
	running.  The purpose of each of these files will be briefly
	described.  The exact syntax and usage of all of these files is
	described in &man.xdm.1;.</para>

      <para>The default configuration is a simple rectangular login
	window with the hostname of the machine displayed at the top in
	a large font and <quote>Login:</quote> and
	<quote>Password:</quote> prompts below.  This is a good starting
	point for changing the look and feel of
	<application>XDM</application> screens.</para>

      <sect3>
	<title>Xaccess</title>

	<para>The protocol for connecting to
	  <application>XDM</application>-controlled displays is called
	  the X Display Manager Connection Protocol (XDMCP).  This file
	  is a ruleset for controlling XDMCP connections from remote
	  machines.  It is ignored unless the <filename>xdm-config</filename>
	  is changed to listen for remote connections.  By default, it does
	  not allow any clients to connect.</para>
      </sect3>

      <sect3>
	<title>Xresources</title>
	<para>This is an application-defaults file for the display
	  chooser and login screens.  In it, the appearance
	  of the login program can be modified.  The format is identical
	  to the app-defaults file described in the
	  X11 documentation.</para>
      </sect3>

      <sect3>
	<title>Xservers</title>
	<para>This is a list of the remote displays the chooser should
	  provide as choices.</para>
      </sect3>

      <sect3>
	<title>Xsession</title>
	<para>This is the default session script for
	  <application>XDM</application> to run after a user has logged
	  in.  Normally each user will have a customized session script
	  in <filename>~/.xsession</filename> that overrides this
	  script.</para>
      </sect3>

      <sect3>
	<title>Xsetup_*</title>
	<para>These will be run automatically before displaying the
	  chooser or login interfaces.  There is a script for each
	  display being used, named <filename>Xsetup_</filename> followed
	  by the local display number (for instance
	  <filename>Xsetup_0</filename>).  Typically these scripts will
	  run one or two programs in the background such as
	  <command>xconsole</command>.</para>
      </sect3>

      <sect3>
	<title>xdm-config</title>
	<para>This contains settings in the form of app-defaults
	  that are applicable to every display that this installation
	  manages.</para>
      </sect3>

      <sect3>
	<title>xdm-errors</title>
	<para>This contains the output of the X servers that
	  <application>XDM</application> is trying to run.  If a display
	  that <application>XDM</application> is trying to start hangs
	  for some reason, this is a good place to look for error
	  messages.  These messages are also written to the user's
	  <filename>~/.xsession-errors</filename> file on a per-session
	  basis.</para>
      </sect3>
    </sect2>

    <sect2>
      <title>Running a Network Display Server</title>

      <para>In order for other clients to connect to the display
	server, you must edit the access control rules and enable the connection
	listener.  By default these are set to conservative values.
	To make <application>XDM</application> listen for connections,
	first comment out a line in the <filename>xdm-config</filename>
	file:</para>

      <screen>! 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</screen>

      <para>and then restart <application>XDM</application>.  Remember that
	comments in app-defaults files begin with a <quote>!</quote>
	character, not the usual <quote>#</quote>.  More strict
	access controls may be desired &mdash; look at the example
	entries in <filename>Xaccess</filename>, and refer to the
	&man.xdm.1; manual page for further information.</para>
    </sect2>

     <sect2>
	<title>Replacements for XDM</title>

	<para>Several replacements for the default
	  <application>XDM</application> program exist.  One of them,
	  <application>kdm</application> (bundled with
	  <application>KDE</application>) is described later in this
	  chapter.  The <application>kdm</application> display manager offers many visual
	  improvements and cosmetic frills, as well as the
	  functionality to allow users to choose their window manager
	  of choice at login time.</para>
     </sect2>
  </sect1>

  <sect1 id="x11-wm">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Valentino</firstname>
	  <surname>Vaschetto</surname>
	  <contrib>Contributed by </contrib>
	</author>
	<!-- June 2001 -->
      </authorgroup>
    </sect1info>

    <title>Desktop Environments</title>

    <para>This section describes the different desktop environments
      available for X on FreeBSD.  A <quote>desktop environment</quote>
      can mean anything ranging from a simple window manager to a
      complete suite of desktop applications, such as
      <application>KDE</application> or <application>GNOME</application>.</para>

    <sect2 id="x11-wm-gnome">
      <title>GNOME</title>

      <sect3 id="x11-wm-gnome-about">
	<title>About GNOME</title>

	<indexterm><primary>GNOME</primary></indexterm>
	<para><application>GNOME</application> is a user-friendly
	  desktop environment that enables users to easily use and
	  configure their computers.  <application>GNOME</application>
	  includes a panel (for starting applications and displaying
	  status), a desktop (where data and applications can be
	  placed), a set of standard desktop tools and applications, and
	  a set of conventions that make it easy for applications to
	  cooperate and be consistent with each other.  Users of other
	  operating systems or environments should feel right at home
	  using the powerful graphics-driven environment that
	  <application>GNOME</application> provides.  More
	  information regarding <application>GNOME</application> on
	  FreeBSD can be found on the <ulink
	  url="http://www.FreeBSD.org/gnome">FreeBSD GNOME
	  Project</ulink>'s web site.  The web site also contains fairly
	  comprehensive FAQs about installing, configuring, and managing
	  <application>GNOME</application>.</para>
      </sect3>

      <sect3 id="x11-wm-gnome-install">
	<title>Installing GNOME</title>

	<para>The software can be easily installed from a package or the
	  Ports Collection:</para>

	<para>To install the <application>GNOME</application> package
	  from the network, simply type:</para>

	<screen>&prompt.root; <userinput>pkg_add -r gnome2</userinput></screen>

	<para>To build <application>GNOME</application> from source, use
	  the ports tree:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/x11/gnome2</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>

	<para>For proper operation, <application>GNOME</application> requires
	  the <filename>/proc</filename> filesystem to be mounted.  Add</para>

	<programlisting>proc           /proc       procfs  rw  0   0</programlisting>

	<para>to <filename>/etc/fstab</filename> to mount
	  &man.procfs.5; automatically during
	  startup.</para>

	<para>Once <application>GNOME</application> is installed,
	  the X server must be told to start
	  <application>GNOME</application> instead of a default window
	  manager.</para>

	<para>The easiest way to start
	  <application>GNOME</application> is with
	  <application>GDM</application>, the GNOME Display Manager.
	  <application>GDM</application> is installed as part
	  of the <application>GNOME</application> desktop, although
	  it is disabled by default.  It can be enabled by adding this
	  line to <filename>/etc/rc.conf</filename>:</para>

	<programlisting>gdm_enable="YES"</programlisting>

	<para>Once you have rebooted,
	  <application>GDM</application> will start automatically.</para>

	<para>It is often desirable to start all
	  <application>GNOME</application> services together with
	  <application>GDM</application>.  To achieve this, add the
	  following line to <filename>/etc/rc.conf</filename>:</para>

	<programlisting>gnome_enable="YES"</programlisting>

	<para><application>GNOME</application> may also be started
	  from the command-line by properly configuring a file named
	  <filename>.xinitrc</filename>.
	  If a custom <filename>.xinitrc</filename> is already in
	  place, simply replace the line that starts the current window
	  manager with one that starts
	  <application>/usr/local/bin/gnome-session</application> instead.
	  If nothing special has been done to the configuration file,
	  then it is enough simply to type:</para>

	<screen>&prompt.user; <userinput>echo "/usr/local/bin/gnome-session" &gt; ~/.xinitrc</userinput></screen>

	<para>Next, type <command>startx</command>, and the
	  <application>GNOME</application> desktop environment will be
	  started.</para>

	<note><para>If an older display manager, like
	  <application>XDM</application>, is being used, this will not work.
	  Instead, create an executable <filename>.xsession</filename>
	  file with the same command in it.  To do this, edit the file
	  and replace the existing window manager command with
	  <application>/usr/local/bin/gnome-session</application>:
	  </para></note>

	<screen>&prompt.user; <userinput>echo "#!/bin/sh" &gt; ~/.xsession</userinput>
&prompt.user; <userinput>echo "/usr/local/bin/gnome-session" &gt;&gt; ~/.xsession</userinput>
&prompt.user; <userinput>chmod +x ~/.xsession</userinput></screen>

	<para>Yet another option is to configure the display manager to
	  allow choosing the window manager at login time; the section on
	  <link linkend="x11-wm-kde-details">KDE details</link>
	  explains how to do this for <application>kdm</application>, the
	  display manager of <application>KDE</application>.</para>
      </sect3>
    </sect2>

    <sect2 id="x11-wm-kde">
      <title>KDE</title>

      <indexterm><primary>KDE</primary></indexterm>
      <sect3 id="x11-wm-kde-about">
	<title>About KDE</title>

	<para><application>KDE</application> is an easy to use
	  contemporary desktop environment.  Some of the things that
	  <application>KDE</application> brings to the user are:</para>

	<itemizedlist>
	  <listitem>
	    <para>A beautiful contemporary desktop</para>
	  </listitem>

	  <listitem>
	    <para>A desktop exhibiting complete network transparency</para>
	  </listitem>

	  <listitem>
	    <para>An integrated help system allowing for convenient,
	      consistent access to help on the use of the
	      <application>KDE</application> desktop and its
	      applications</para>
	  </listitem>

	  <listitem>
	    <para>Consistent look and feel of all
	      <application>KDE</application> applications</para>
	  </listitem>

	  <listitem>
	    <para>Standardized menu and toolbars, keybindings, color-schemes,
	      etc.</para>
	  </listitem>

	  <listitem>
	    <para>Internationalization: <application>KDE</application>
	      is available in more than 40 languages</para>
	  </listitem>

	  <listitem>
	    <para>Centralized, consistent, dialog-driven desktop
	      configuration</para>
	  </listitem>

	  <listitem>
	    <para>A great number of useful
	      <application>KDE</application> applications</para>
	  </listitem>
	</itemizedlist>

	<para><application>KDE</application> comes with a web browser called
	  <application>Konqueror</application>, which is
	  a solid competitor to other existing web browsers on &unix;
	  systems.  More information on <application>KDE</application>
	  can be found on the <ulink url="http://www.kde.org/">KDE
	  website</ulink>.  For FreeBSD specific information and
	  resources on <application>KDE</application>, consult
	  the <ulink url="http://freebsd.kde.org/">KDE on FreeBSD
	  team</ulink>'s website.</para>

	<para>There are two versions of <application>KDE</application> available on FreeBSD.  Version 3
	  has been around for a long time, and is very mature.  Version 4,
	  the next generation, is also available in the Ports Collection.
	  They can even be installed side by side.</para>
      </sect3>

      <sect3 id="x11-wm-kde-install">
	<title>Installing KDE</title>

	<para>Just as with <application>GNOME</application> or any
	  other desktop environment, the software can be easily installed
	  from a package or the Ports Collection:</para>

	<para>To install the <application>KDE3</application> package
	  from the network, simply type:</para>

	<screen>&prompt.root; <userinput>pkg_add -r kde</userinput></screen>

	<para>To install the <application>KDE4</application> package
	  from the network, simply type:</para>

	<screen>&prompt.root; <userinput>pkg_add -r kde4</userinput></screen>

	<para>&man.pkg.add.1; will automatically fetch the latest version
	  of the application.</para>

	<para>To build <application>KDE3</application> from source,
	  use the ports tree:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/x11/kde3</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>

	<para>To build <application>KDE4</application> from source,
	  use the ports tree:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/x11/kde4</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>

	<para>After <application>KDE</application> has been installed,
	  the X server must be told to launch this application
	  instead of the default window manager.  This is accomplished
	  by editing the <filename>.xinitrc</filename> file:</para>

	<para>For <application>KDE3</application>:</para>
	
	<screen>&prompt.user; <userinput>echo "exec startkde" &gt; ~/.xinitrc</userinput></screen>

	<para>For <application>KDE4</application>:</para>
	
	<screen>&prompt.user; <userinput>echo "exec /usr/local/kde4/bin/startkde" &gt; ~/.xinitrc</userinput></screen>

	<para>Now, whenever the X Window System is invoked with
	  <command>startx</command>,
	  <application>KDE</application> will be the desktop.</para>

	<para>If a display manager such as
	  <application>XDM</application> is being used, the
	  configuration is slightly different.  Edit the
	  <filename>.xsession</filename> file instead.  Instructions
	  for <application>kdm</application> are described later in
	  this chapter.</para>
      </sect3>
    </sect2>

    <sect2 id="x11-wm-kde-details">
	<title>More Details on KDE</title>

	<para>Now that <application>KDE</application> is installed on
	  the system, most things can be discovered through the
	  help pages, or just by pointing and clicking at various menus.
	  &windows; or &mac; users will feel quite at home.</para>

	<para>The best reference for <application>KDE</application> is
	  the on-line documentation.  <application>KDE</application>
	  comes with its own web browser,
	  <application>Konqueror</application>, dozens of useful
	  applications, and extensive documentation.  The remainder of
	  this section discusses the technical items that are
	  difficult to learn by random exploration.</para>

      <sect3 id="x11-wm-kde-kdm">
	<title>The KDE Display Manager</title>

	<indexterm><primary>KDE</primary>
	  <secondary>display manager</secondary></indexterm>
	<para>An administrator of a multi-user system may wish to have
	  a graphical login screen to welcome users.
	  <link linkend="x-xdm">XDM</link> can be
	  used, as described earlier.  However,
	  <application>KDE</application> includes an
	  alternative, <application>kdm</application>, which is designed
	  to look more attractive and include more login-time options.
	  In particular, users can easily choose (via a menu) which
	  desktop environment (<application>KDE</application>,
	  <application>GNOME</application>, or something else) to run
	  after logging on.</para>

	<para>To enable <application>kdm</application>, different files
	  need to be edited depending on the version of
	  <application>KDE</application>.</para>

	<para>For <application>KDE3</application>, the <literal>ttyv8</literal>
	  entry in <filename>/etc/ttys</filename> has to be adapted as
	  follows:</para>

	 <programlisting>ttyv8 "/usr/local/bin/kdm -nodaemon" xterm on secure</programlisting>

	<para>For <application>KDE4</application>, you have to add the
	  following lines to <filename>/etc/rc.conf</filename>:</para>

	<programlisting>local_startup="${local_startup} /usr/local/kde4/etc/rc.d"
kdm4_enable="YES"</programlisting>
      </sect3>

     </sect2>

     <sect2 id="x11-wm-xfce">
	 <title>Xfce</title>
       <sect3 id="x11-wm-xfce-about">
	 <title>About Xfce</title>

	<para><application>Xfce</application> is a desktop environment
	  based on the GTK+
	  toolkit used by <application>GNOME</application>, but is much
	  more lightweight and meant for those who want a simple,
	  efficient desktop which is nevertheless easy to use and
	  configure.  Visually, it looks very much like
	  <application>CDE</application>, found on commercial &unix;
	  systems.  Some of <application>Xfce</application>'s features
	  are:</para>

	  <itemizedlist>
	    <listitem>
	      <para>A simple, easy-to-handle desktop</para>
	    </listitem>

	    <listitem>
	      <para>Fully configurable via mouse, with drag and
		drop, etc.</para>
	    </listitem>

	    <listitem>
	      <para>Main panel similar to <application>CDE</application>, with
		menus, applets and applications launchers</para>
	    </listitem>

	    <listitem>
	      <para>Integrated window manager, file manager, sound manager,
		<application>GNOME</application> compliance module, and more</para>
	    </listitem>

	    <listitem>
	      <para>Themeable (since it uses GTK+)</para>
	    </listitem>

	    <listitem>
	      <para>Fast, light and efficient: ideal for older/slower machines
		or machines with memory limitations</para>
	    </listitem>
	  </itemizedlist>

	 <para>More information on <application>Xfce</application>
	  can be found on the <ulink url="http://www.xfce.org/">Xfce
	  website</ulink>.</para>
       </sect3>

       <sect3 id="x11-wm-xfce-install">
	 <title>Installing Xfce</title>

	<para>A binary package for <application>Xfce</application>
	  exists (at the time of writing).  To install, simply type:</para>

	<screen>&prompt.root; <userinput>pkg_add -r xfce4</userinput></screen>

	<para>Alternatively, to build from source, use the
	  Ports Collection:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/x11-wm/xfce4</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>

	<para>Now, tell the X server to launch
	  <application>Xfce</application> the next time X is started.
	    Simply type this:</para>

	<screen>&prompt.user; <userinput>echo "/usr/local/bin/startxfce4" &gt; ~/.xinitrc</userinput></screen>

	<para>The next time X is started,
	  <application>Xfce</application> will be the desktop.
	  As before, if a display manager like
	  <application>XDM</application> is being used, create an
	  <filename>.xsession</filename>, as described in the
	  section on <link linkend="x11-wm-gnome">GNOME</link>, but
	  with the <filename>/usr/local/bin/startxfce4</filename>
	  command; or, configure the display manager to allow
	  choosing a desktop at login time, as explained in
	  the section on <link linkend="x11-wm-kde-kdm">kdm</link>.</para>
      </sect3>
    </sect2>
  </sect1>

</chapter>

<!--
     Local Variables:
     mode: sgml
     sgml-declaration: "../chapter.decl"
     sgml-indent-data: t
     sgml-omittag: nil
     sgml-always-quote-attributes: t
     sgml-parent-document: ("../book.sgml" "part" "chapter")
     End:
-->