aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/x11/chapter.xml
blob: 781351c695c0c6c0770405d4151657af27435f67 (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
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->
<chapter xmlns="http://docbook.org/ns/docbook"
  xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
  xml: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 xml:id="x11-synopsis">
    <title>Synopsis</title>

    <para>An installation of &os; using
      <application>bsdinstall</application> does not automatically
      install a graphical user interface.  This chapter describes how
      to install and configure <application>&xorg;</application>,
      which provides the open source X Window System used to provide a
      graphical environment.  It then describes how to find and
      install a desktop environment or window manager.</para>

    <note>
      <para>Users who prefer an installation method that automatically
	configures the <application>&xorg;</application> and offers a
	choice of window managers during installation should refer to
	the <link xlink:href="http://www.trueos.org/" />
	website.</para>
    </note>

    <para>For more information on the video hardware that
      <application>&xorg;</application> supports, refer to the <link
	xlink:href="http://www.x.org/">x.org</link> website.</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
	  <application>&xorg;</application>.</para>
      </listitem>

      <listitem>
	<para>How to install and configure several window managers
	  and desktop environments.</para>
      </listitem>

      <listitem>
	<para>How to use &truetype; fonts in
	  <application>&xorg;</application>.</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 as described in <xref linkend="ports"/>.</para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 xml:id="x-understanding">
    <title>Terminology</title>

    <para>While it is not necessary to understand all of the details
      of the various components in the X Window System and how they
      interact, some basic knowledge of these components can be
      useful.</para>

    <variablelist>
      <varlistentry>
	<term>X server</term>

	<listitem>
	  <para>X was designed from the beginning to be
	    network-centric, and adopts a <quote>client-server</quote>
	    model.  In this 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 handling input or output from other devices
	    such as a tablet or a video projector.  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>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>X client</term>

	<listitem>
	  <para>Each X application, such as
	    <application>XTerm</application> or
	    <application>Firefox</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.  It
	    is also possible to run the X server on a less powerful
	    computer and to run the X applications on a more powerful
	    system.  In this scenario, the communication between the X
	    client and server takes place over the network.</para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>window manager</term>

	<listitem>
	  <para>X does not dictate what windows should look like
	    on-screen, how to move them around with the mouse, which
	    keystrokes should be used to move between windows, what
	    the title bars on each window should look like, whether or
	    not they have close buttons on them, and so on.  Instead,
	    X delegates this responsibility to a separate window
	    manager application.  There are <link
	      xlink:href="http://www.xwinman.org/">dozens of window
	      managers</link> available.  Each window manager provides
	    a different look and feel: some support virtual desktops,
	    some allow customized keystrokes to manage the desktop,
	    some have a <quote>Start</quote> button, and some are
	    themeable, allowing a complete change of the desktop's
	    look-and-feel.  Window managers are available in the
	    <filename>x11-wm</filename> category of the Ports
	    Collection.</para>

	  <para>Each window manager uses a different configuration
	    mechanism.  Some expect configuration file written by hand
	    while others provide graphical tools for most
	    configuration tasks.</para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>desktop environment</term>

	<listitem>
	  <para><application>KDE</application> and
	    <application>GNOME</application> are considered to be
	    desktop environments as they include an entire suite of
	    applications for performing common desktop tasks.  These
	    may include office suites, web browsers, and games.</para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>focus policy</term>

	<listitem>
	  <para>The window manager is responsible for the mouse focus
	    policy.  This policy provides some means for choosing
	    which window is actively receiving keystrokes and it
	    should also visibly indicate which window is currently
	    active.</para>

	  <para>One focus policy is called
	    <quote>click-to-focus</quote>.  In this model, a window
	    becomes active upon receiving a mouse click.  In the
	    <quote>focus-follows-mouse</quote> policy, the window that
	    is under the mouse pointer has focus and the focus is
	    changed by pointing at another window.  If the mouse is
	    over the root window, then this window is focused.  In the
	    <quote>sloppy-focus</quote> model, if the mouse is moved
	    over the root window, the most recently used window still
	    has the focus.  With sloppy-focus, focus is only changed
	    when the cursor enters a new window, and not when exiting
	    the current window.  In the <quote>click-to-focus</quote>
	    policy, the active window is selected by mouse click.  The
	    window may then be raised 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>

	  <para>Different window managers support different focus
	    models.  All of them support click-to-focus, and the
	    majority of them also support other policies.  Consult the
	    documentation for the window manager to determine which
	    focus models are available.</para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>widgets</term>

	<listitem>
	  <para>Widget is a term for all of the items in the user
	    interface that can be clicked or manipulated in some way.
	    This includes buttons, check boxes, radio buttons, icons,
	    and lists.  A widget toolkit is a set of widgets used to
	    create graphical applications.  There are several popular
	    widget toolkits, including Qt, used by
	    <application>KDE</application>, and GTK+, used by
	    <application>GNOME</application>.  As a result,
	    applications will have a different look and feel,
	    depending upon which widget toolkit was used to create the
	    application.</para>
	</listitem>
      </varlistentry>
    </variablelist>
  </sect1>

  <sect1 xml:id="x-install">
    <title>Installing <application>&xorg;</application></title>

    <para>On &os;, <application>&xorg;</application> can be installed
      as a package or port.</para>

    <para>The binary package can be installed quickly but with
      fewer options for customization:</para>

    <screen>&prompt.root; <userinput>pkg install xorg</userinput></screen>

    <para>To build and install from the Ports Collection:</para>

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

    <para>Either of these installations results in the complete
      <application>&xorg;</application> system being installed.  Binary packages
      are the best option for most users.</para>

    <para>A smaller version of the X system suitable for experienced
      users is available in <package>x11/xorg-minimal</package>.  Most
      of the documents, libraries, and applications will not be
      installed.  Some applications require these additional
      components to function.</para>
  </sect1>

  <sect1 xml:id="x-config">
    <title><application>&xorg;</application> Configuration</title>

    <info>
      <author>
	<personname>
	  <firstname>Warren</firstname>
	  <surname>Block</surname>
	</personname>
	<contrib>Originally contributed by</contrib>
      </author>
    </info>

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

    <sect2 xml:id="x-config-quick-start">
      <title>Quick Start</title>

      <para><application>&xorg;</application> supports most common
	video cards, keyboards, and pointing devices.</para>

      <tip>
	<para>Video cards, monitors, and input devices are
	  automatically detected and do not require any manual
	  configuration.  Do not create <filename>xorg.conf</filename>
	  or run a <option>-configure</option> step unless automatic
	  configuration fails.</para>
      </tip>

      <procedure>
	<step>
	  <para>If <application>&xorg;</application> has been used on
	    this computer before, move or remove any existing
	    configuration files:</para>

	  <screen>&prompt.root; <userinput>mv /etc/X11/xorg.conf ~/xorg.conf.etc</userinput>
&prompt.root; <userinput>mv /usr/local/etc/X11/xorg.conf ~/xorg.conf.localetc</userinput></screen>
	</step>

	<step>
	  <para>Add the user who will run
	    <application>&xorg;</application> to the
	    <literal>video</literal> or
	    <literal>wheel</literal> group to enable 3D acceleration
	    when available.  To add user
	    <replaceable>jru</replaceable> to whichever group is
	    available:</para>

	  <screen>&prompt.root; <userinput>pw groupmod video -m <replaceable>jru</replaceable> || pw groupmod wheel -m <replaceable>jru</replaceable></userinput></screen>
	</step>

	<step>
	  <para>The <acronym>TWM</acronym> window manager is included
	    by default.  It is started when
	    <application>&xorg;</application> starts:</para>

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

	<step>
	  <para>On some older versions of &os;, the system console
	    must be set to &man.vt.4; before switching back to the
	    text console will work properly.  See
	    <xref linkend="x-config-kms"/>.</para>
	</step>
      </procedure>
    </sect2>

    <sect2 xml:id="x-config-user-group">
      <title>User Group for Accelerated Video</title>

      <para>Access to <filename>/dev/dri</filename> is needed to allow
	3D acceleration on video cards.  It is usually simplest to add
	the user who will be running X to either the
	<literal>video</literal> or <literal>wheel</literal> group.
	Here, &man.pw.8; is used to add user
	<replaceable>slurms</replaceable> to the
	<literal>video</literal> group, or to the
	<literal>wheel</literal> group if there is no
	<literal>video</literal> group:</para>

      <screen>&prompt.root; <userinput>pw groupmod video -m <replaceable>slurms</replaceable> || pw groupmod wheel -m <replaceable>slurms</replaceable></userinput></screen>
    </sect2>

    <sect2 xml:id="x-config-kms">
      <title>Kernel Mode Setting (<acronym>KMS</acronym>)</title>

      <para>When the computer switches from displaying the console to
	a higher screen resolution for X, it must set the video
	output <emphasis>mode</emphasis>.  Recent versions of
	<acronym>&xorg;</acronym> use a system inside the kernel to do
	these mode changes more efficiently.  Older versions of &os;
	use &man.sc.4;, which is not aware of the
	<acronym>KMS</acronym> system.  The end result is that after
	closing X, the system console is blank, even though it is
	still working.  The newer &man.vt.4; console avoids this
	problem.</para>

      <para>Add this line to <filename>/boot/loader.conf</filename>
	to enable &man.vt.4;:</para>

      <programlisting>kern.vty=vt</programlisting>
    </sect2>

    <sect2 xml:id="x-config-files">
      <title>Configuration Files</title>

      <para>Manual configuration is usually not necessary.  Please do
	not manually create configuration files unless
	autoconfiguration does not work.</para>

      <sect3 xml:id="x-config-files-directory">
	<title>Directory</title>

	<para><application>&xorg;</application> looks in several
	  directories for configuration files.
	  <filename>/usr/local/etc/X11/</filename> is the recommended
	  directory for these files on &os;.  Using this directory
	  helps keep application files separate from operating system
	  files.</para>

	<para>Storing configuration files in the legacy
	  <filename>/etc/X11/</filename> still works.  However, this
	  mixes application files with the base &os; files and is not
	  recommended.</para>
      </sect3>

      <sect3 xml:id="x-config-files-single-or-multi">
	<title>Single or Multiple Files</title>

	<para>It is easier to use multiple files that each configure a
	  specific setting than the traditional single
	  <filename>xorg.conf</filename>.  These files are stored in
	  the <filename>xorg.conf.d/</filename> subdirectory of the
	  main configuration file directory.  The full path is
	  typically
	  <filename>/usr/local/etc/X11/xorg.conf.d/</filename>.</para>

	<para>Examples of these files are shown later in this
	  section.</para>

	<para>The traditional single <filename>xorg.conf</filename>
	  still works, but is neither as clear nor as flexible as
	  multiple files in the <filename>xorg.conf.d/</filename>
	  subdirectory.</para>
      </sect3>
    </sect2>

    <sect2 xml:id="x-config-video-cards">
      <title>Video Cards</title>

      <variablelist>
	<varlistentry xml:id="x-config-video-cards-intel">
	  <term>&intel;</term>

	  <listitem>
	    <para>3D acceleration is supported on most &intel;
	      graphics up to Ivy Bridge (HD Graphics 2500, 4000, and
	      P4000), including Iron Lake (HD Graphics) and
	      Sandy Bridge (HD Graphics 2000).</para>

	    <para>Driver name: <literal>intel</literal></para>

	    <para>For reference, see <link
		xlink:href="https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units"/>.</para>
	  </listitem>
	</varlistentry>

	<varlistentry xml:id="x-config-video-cards-radeon">
	  <term>&amd; Radeon</term>

	  <listitem>
	    <para>2D and 3D acceleration is supported on Radeon
	      cards up to and including the HD6000 series.</para>

	    <para>Driver name: <literal>radeon</literal></para>

	    <para>For reference, see <link
		xlink:href="https://en.wikipedia.org/wiki/List_of_AMD_graphics_processing_units"/>.</para>
	  </listitem>
	</varlistentry>

	<varlistentry xml:id="x-config-video-cards-nvidia">
	  <term>NVIDIA</term>

	  <listitem>
	    <para>Several NVIDIA drivers are available in the
	      <filename>x11</filename> category of the Ports
	      Collection.  Install the driver that matches the video
	      card.</para>

	    <para>For reference, see <link
		xlink:href="https://en.wikipedia.org/wiki/List_of_Nvidia_graphics_processing_units"/>.</para>
	  </listitem>
	</varlistentry>

	<varlistentry xml:id="x-config-video-cards-hybrid">
	  <term>Hybrid Combination Graphics</term>

	  <listitem>
	    <para>Some notebook computers add additional graphics
	      processing units to those built into the chipset or
	      processor.  <emphasis>Optimus</emphasis> combines
	      &intel; and NVIDIA hardware.
	      <emphasis>Switchable Graphics</emphasis> or
	      <emphasis>Hybrid Graphics</emphasis> are a combination
	      of an &intel; or &amd; processor and an &amd; Radeon
	      <acronym>GPU</acronym>.</para>

	    <para>Implementations of these hybrid graphics systems
	      vary, and <application>&xorg;</application> on &os; is
	      not able to drive all versions of them.</para>

	    <para>Some computers provide a <acronym>BIOS</acronym>
	      option to disable one of the graphics adapters or select
	      a <emphasis>discrete</emphasis> mode which can be used
	      with one of the standard video card drivers.  For
	      example, it is sometimes possible to disable the NVIDIA
	      <acronym>GPU</acronym> in an Optimus system.  The
	      &intel; video can then be used with an &intel;
	      driver.</para>

	    <para><acronym>BIOS</acronym> settings depend on the model
	      of computer.  In some situations, both
	      <acronym>GPU</acronym>s can be left enabled, but
	      creating a configuration file that only uses the main
	      <acronym>GPU</acronym> in the <literal>Device</literal>
	      section is enough to make such a system
	      functional.</para>
	  </listitem>
	</varlistentry>

	<varlistentry xml:id="x-config-video-cards-other">
	  <term>Other Video Cards</term>

	  <listitem>
	    <para>Drivers for some less-common video cards can be
	      found in the <filename>x11-drivers</filename> directory
	      of the Ports Collection.</para>

	    <para>Cards that are not supported by a specific driver
	      might still be usable with the
	      <package>x11-drivers/xf86-video-vesa</package> driver.
	      This driver is installed by <package>x11/xorg</package>.
	      It can also be installed manually as
	      <package>x11-drivers/xf86-video-vesa</package>.
	      <application>&xorg;</application> attempts to use this
	      driver when a specific driver is not found for the video
	      card.</para>

	    <para><package>x11-drivers/xf86-video-scfb</package> is a
	      similar nonspecialized video driver that works on many
	      <acronym>UEFI</acronym> and &arm; computers.</para>
	  </listitem>
	</varlistentry>

	<varlistentry xml:id="x-config-video-cards-file">
	  <term>Setting the Video Driver in a File</term>

	  <listitem>
	    <para>To set the &intel; driver in a configuration
	      file:</para>

	    <example xml:id="x-config-video-cards-file-intel">
	      <title>Select &intel; Video Driver in a File</title>

	      <para><filename>/usr/local/etc/X11/xorg.conf.d/driver-intel.conf</filename></para>

	      <programlisting>Section "Device"
	Identifier "Card0"
	Driver     "intel"
	# BusID    "PCI:1:0:0"
EndSection</programlisting>

	      <para>If more than one video card is present, the
		<literal>BusID</literal> identifier can be uncommented
		and set to select the desired card.  A list of video
		card bus <acronym>ID</acronym>s can be displayed with
		<command>pciconf -lv | grep -B3
		  display</command>.</para>
	    </example>

	    <para>To set the Radeon driver in a configuration
	      file:</para>

	    <example xml:id="x-config-video-cards-file-radeon">
	      <title>Select Radeon Video Driver in a File</title>

	      <para><filename>/usr/local/etc/X11/xorg.conf.d/driver-radeon.conf</filename></para>

	      <programlisting>Section "Device"
	Identifier "Card0"
	Driver     "radeon"
EndSection</programlisting>
	    </example>

	    <para>To set the <acronym>VESA</acronym> driver in a
	      configuration file:</para>

	    <example xml:id="x-config-video-cards-file-vesa">
	      <title>Select <acronym>VESA</acronym> Video Driver in a
		File</title>

	      <para><filename>/usr/local/etc/X11/xorg.conf.d/driver-vesa.conf</filename></para>

	      <programlisting>Section "Device"
	Identifier "Card0"
	Driver     "vesa"
EndSection</programlisting>
	    </example>

	    <para>To set the <literal>scfb</literal> driver for use
	      with a <acronym>UEFI</acronym> or &arm; computer:</para>

	    <example xml:id="x-config-video-cards-file-scfb">
	      <title>Select <literal>scfb</literal> Video Driver in a
		File</title>

	      <para><filename>/usr/local/etc/X11/xorg.conf.d/driver-scfb.conf</filename></para>

	      <programlisting>Section "Device"
	Identifier "Card0"
	Driver     "scfb"
EndSection</programlisting>
	    </example>
	  </listitem>
	</varlistentry>
      </variablelist>
    </sect2>

    <sect2 xml:id="x-config-monitors">
      <title>Monitors</title>

      <para>Almost all monitors support the Extended Display
	Identification Data standard (<acronym>EDID</acronym>).
	<application>&xorg;</application> uses <acronym>EDID</acronym>
	to communicate with the monitor and detect the supported
	resolutions and refresh rates.  Then it selects the most
	appropriate combination of settings to use with that
	monitor.</para>

      <para>Other resolutions supported by the monitor can be
	chosen by setting the desired resolution in configuration
	files, or after the X server has been started with
	&man.xrandr.1;.</para>

      <variablelist>
	<varlistentry xml:id="x-config-monitors-xrandr">
	  <term>Using &man.xrandr.1;</term>

	  <listitem>
	    <para>Run &man.xrandr.1; without any parameters to see a
	      list of video outputs and detected monitor modes:</para>

	    <screen>&prompt.user; <userinput>xrandr</userinput>
Screen 0: minimum 320 x 200, current 3000 x 1920, maximum 8192 x 8192
DVI-0 connected primary 1920x1200+1080+0 (normal left inverted right x axis y axis) 495mm x 310mm
   1920x1200     59.95*+
   1600x1200     60.00
   1280x1024     85.02    75.02    60.02
   1280x960      60.00
   1152x864      75.00
   1024x768      85.00    75.08    70.07    60.00
   832x624       74.55
   800x600       75.00    60.32
   640x480       75.00    60.00
   720x400       70.08
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)</screen>

	    <para>This shows that the <literal>DVI-0</literal> output
	      is being used to display a screen resolution of
	      1920x1200 pixels at a refresh rate of about 60 Hz.
	      Monitors are not attached to the
	      <literal>DisplayPort-0</literal> and
	      <literal>HDMI-0</literal> connectors.</para>

	    <para>Any of the other display modes can be selected with
	      &man.xrandr.1;.  For example, to switch to 1280x1024 at
	      60 Hz:</para>

	    <screen>&prompt.user; <userinput>xrandr --mode 1280x1024 --rate 60</userinput></screen>

	    <para>A common task is using the external video output on
	      a notebook computer for a video projector.</para>

	    <para>The type and quantity of output connectors varies
	      between devices, and the name given to each output
	      varies from driver to driver.  What one driver calls
	      <literal>HDMI-1</literal>, another might call
	      <literal>HDMI1</literal>.  So the first step is to run
	      &man.xrandr.1; to list all the available
	      outputs:</para>

	    <screen>&prompt.user; <userinput>xrandr</userinput>
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1366x768      60.04*+
   1024x768      60.00
   800x600       60.32    56.25
   640x480       59.94
VGA1 connected (normal left inverted right x axis y axis)
   1280x1024     60.02 +  75.02
   1280x960      60.00
   1152x864      75.00
   1024x768      75.08    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   640x480       75.00    72.81    66.67    60.00
   720x400       70.08
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)</screen>

	    <para>Four outputs were found: the built-in panel
	      <literal>LVDS1</literal>, and external
	      <literal>VGA1</literal>, <literal>HDMI1</literal>, and
	      <literal>DP1</literal> connectors.</para>

	    <para>The projector has been connected to the
	      <literal>VGA1</literal> output.  &man.xrandr.1; is now
	      used to set that output to the native resolution of the
	      projector and add the additional space to the right side
	      of the desktop:</para>

	    <screen>&prompt.user; <userinput>xrandr --output VGA1 --auto --right-of LVDS1</userinput></screen>

	    <para><literal>--auto</literal> chooses the resolution and
	      refresh rate detected by <acronym>EDID</acronym>.  If
	      the resolution is not correctly detected, a fixed value
	      can be given with <literal>--mode</literal> instead of
	      the <literal>--auto</literal> statement.  For example,
	      most projectors can be used with a 1024x768 resolution,
	      which is set with
	      <literal>--mode 1024x768</literal>.</para>

	    <para>&man.xrandr.1; is often run from
	      <filename>.xinitrc</filename> to set the appropriate
	      mode when X starts.</para>
	  </listitem>
	</varlistentry>

	<varlistentry xml:id="x-config-monitors-files">
	  <term>Setting Monitor Resolution in a File</term>

	  <listitem>
	    <para>To set a screen resolution of 1024x768 in a
	      configuration file:</para>

	    <example>
	      <title>Set Screen Resolution in a File</title>

	      <para><filename>/usr/local/etc/X11/xorg.conf.d/screen-resolution.conf</filename></para>

	      <programlisting>Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	SubSection "Display"
	Modes      "1024x768"
	EndSubSection
EndSection</programlisting>
	    </example>

	    <para>The few monitors that do not have
	      <acronym>EDID</acronym> can be configured by setting
	      <literal>HorizSync</literal> and
	      <literal>VertRefresh</literal> to the range of
	      frequencies supported by the monitor.</para>

	    <example>
	      <title>Manually Setting Monitor Frequencies</title>

	      <para><filename>/usr/local/etc/X11/xorg.conf.d/monitor0-freq.conf</filename></para>

	      <programlisting>Section "Monitor"
	Identifier   "Monitor0"
	HorizSync    30-83   # kHz
	VertRefresh  50-76   # Hz
EndSection</programlisting>
	    </example>
	  </listitem>
	</varlistentry>
      </variablelist>
    </sect2>

    <sect2 xml:id="x-config-input">
      <title>Input Devices</title>

      <sect3 xml:id="x-config-input-keyboard">
	<title>Keyboards</title>

	<variablelist>
	  <varlistentry xml:id="x-config-input-keyboard-layout">
	    <term>Keyboard Layout</term>

	    <listitem>
	      <para>The standardized location of keys on a keyboard
		is called a <emphasis>layout</emphasis>.  Layouts and
		other adjustable parameters are listed in
		&man.xkeyboard-config.7;.</para>

	      <para>A United States layout is the default.  To select
		an alternate layout, set the
		<literal>XkbLayout</literal> and
		<literal>XkbVariant</literal> options in an
		<literal>InputClass</literal>.  This will be applied
		to all input devices that match the class.</para>

	      <para>This example selects a French keyboard layout with
		the <literal>oss</literal> variant.</para>

	      <example>
		<title>Setting a Keyboard Layout</title>

		<para><filename>/usr/local/etc/X11/xorg.conf.d/keyboard-fr-oss.conf</filename></para>

		<programlisting>Section	"InputClass"
	Identifier	"KeyboardDefaults"
	Driver		"keyboard"
	MatchIsKeyboard	"on"
	Option		"XkbLayout" "fr"
	Option		"XkbVariant" "oss"
EndSection</programlisting>
	      </example>

	      <example>
		<title>Setting Multiple Keyboard Layouts</title>

		<para>Set United States, Spanish, and Ukrainian
		  keyboard layouts.  Cycle through these layouts by
		  pressing
		  <keycombo action="simul">
		    <keycap>Alt</keycap>
		    <keycap>Shift</keycap>
		  </keycombo>.  <package>x11/xxkb</package> or
		  <package>x11/sbxkb</package> can be used for
		  improved layout switching control and
		  current layout indicators.</para>

		<para><filename>/usr/local/etc/X11/xorg.conf.d/kbd-layout-multi.conf</filename></para>

		<programlisting>Section	"InputClass"
	Identifier	"All Keyboards"
	MatchIsKeyboard	"yes"
	Option		"XkbLayout" "us, es, ua"
EndSection</programlisting>
	      </example>
	    </listitem>
	  </varlistentry>

	  <varlistentry xml:id="x-config-input-keyboard-zap">
	    <term>Closing <application>&xorg;</application> From the
	    Keyboard</term>

	    <listitem>
	      <para>X can be closed with a combination of keys.
		By default, that key combination is not set because it
		conflicts with keyboard commands for some
		applications.  Enabling this option requires changes
		to the keyboard <literal>InputDevice</literal>
		section:</para>

	      <example>
		<title>Enabling Keyboard Exit from X</title>

		<para><filename>/usr/local/etc/X11/xorg.conf.d/keyboard-zap.conf</filename></para>

		<programlisting>Section	"InputClass"
	Identifier	"KeyboardDefaults"
	Driver		"keyboard"
	MatchIsKeyboard	"on"
	Option		"XkbOptions" "terminate:ctrl_alt_bksp"
EndSection</programlisting>
	      </example>
	    </listitem>
	  </varlistentry>
	</variablelist>
      </sect3>

      <sect3 xml:id="x11-input-mice">
	<title>Mice and Pointing Devices</title>

	<para>Many mouse parameters can be adjusted with configuration
	  options.  See &man.mousedrv.4x; for a full list.</para>

	<variablelist>
	  <varlistentry xml:id="x11-input-mice-buttons">
	    <term>Mouse Buttons</term>

	    <listitem>
	      <para>The number of buttons on a mouse can be set in the
		mouse <literal>InputDevice</literal> section of
		<filename>xorg.conf</filename>.  To set the number of
		buttons to 7:</para>

	      <example>
		<title>Setting the Number of Mouse Buttons</title>

		<para><filename>/usr/local/etc/X11/xorg.conf.d/mouse0-buttons.conf</filename></para>

		<programlisting>Section "InputDevice"
	Identifier  "Mouse0"
	Option      "Buttons" "7"
EndSection</programlisting>
	      </example>
	    </listitem>
	  </varlistentry>
	</variablelist>
      </sect3>
    </sect2>

    <sect2 xml:id="x-config-manual-configuration">
      <title>Manual Configuration</title>

      <para>In some cases, <application>&xorg;</application>
	autoconfiguration does not work with particular hardware, or a
	different configuration is desired.  For these cases, a custom
	configuration file can be created.</para>

      <warning>
	<para>Do not create manual configuration files unless
	  required.  Unnecessary manual configuration can prevent
	  proper operation.</para>
      </warning>

      <para>A configuration file can be generated by
	<application>&xorg;</application> based on the detected
	hardware.  This file is often a useful starting point for
	custom configurations.</para>

      <para>Generating an <filename>xorg.conf</filename>:</para>

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

      <para>The configuration file is saved to
	<filename>/root/xorg.conf.new</filename>.  Make any changes
	desired, then test that file with:</para>

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

      <para>After the new configuration has been adjusted and tested,
	it can be split into smaller files in the normal location,
	<filename>/usr/local/etc/X11/xorg.conf.d/</filename>.</para>
    </sect2>
  </sect1>

  <sect1 xml:id="x-fonts">
    <!--
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Murray</firstname>
	  <surname>Stokely</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
    </sect1info>
    -->
    <title>Using Fonts in <application>&xorg;</application></title>

    <sect2 xml:id="type1">
      <title>Type1 Fonts</title>

      <para>The default fonts that ship with
	<application>&xorg;</application> are less than ideal for
	typical desktop publishing applications.  Large presentation
	fonts show up jagged and unprofessional looking, and small
	fonts are almost completely unintelligible.  However, there
	are several free, high quality Type1 (&postscript;) fonts
	available which can be readily used with
	<application>&xorg;</application>.  For instance, the URW font
	collection (<package>x11-fonts/urwfonts</package>) 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 (<package>x11-fonts/freefonts</package>)
	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,
	<application>&xorg;</application> 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 <xref
	  linkend="truetype"/>.</para>

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

      <screen>&prompt.root; <userinput>pkg install urwfonts</userinput></screen>

      <para>Alternatively, to build 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/share/fonts/urwfonts/"</programlisting>

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

      <screen>&prompt.user; <userinput>xset fp+ /usr/local/share/fonts/urwfonts</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> as
	demonstrated in <xref linkend="antialias"/>.</para>
    </sect2>

    <sect2 xml: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 <filename>/etc/X11/xorg.conf</filename>.</para>

      <programlisting>Load  "freetype"</programlisting>

      <para>Now make a directory for the &truetype; fonts (for
	example, <filename>/usr/local/share/fonts/TrueType</filename>)
	and copy all of the &truetype; fonts into this directory.
	Keep in mind that &truetype; fonts cannot be directly taken
	from an &apple; &mac;; they must be in
	&unix;/&ms-dos;/&windows; format for use by
	<application>&xorg;</application>.  Once the files have been
	copied into this directory, use
	<application>mkfontdir</application> to create a
	<filename>fonts.dir</filename>, so that the X font renderer
	knows that these new files have been installed.
	<command>mkfontdir</command> can be installed as a
	package:</para>

      <screen>&prompt.root; <userinput>pkg install mkfontdir</userinput></screen>

      <para>Then create an index of X font files in a
	directory:</para>

      <screen>&prompt.root; <userinput>cd /usr/local/share/fonts/TrueType</userinput>
&prompt.root; <userinput>mkfontdir</userinput></screen>

      <para>Now add the &truetype; directory to the font path.  This
	is just the same as described in <xref
	  linkend="type1"/>:</para>

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

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

      <para>Now <application>Gimp</application>,
	<application>Apache OpenOffice</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 xml:id="antialias">
      <!--
      <sect2info>
	<authorgroup>
	  <author>
	    <firstname>Joe Marcus</firstname>
	    <surname>Clarke</surname>
	    <contrib>Updated in May 2003 by</contrib>
	  </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 <application>&xorg;</application> that are
	found in <filename>/usr/local/share/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>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/share/fonts/</filename> as well as
	<filename>~/.fonts/</filename> are already made available to
	Xft-aware applications.  To add another directory
	outside of these two directory trees, add a line like
	this 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, 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 might also be
	inappropriate with anti-aliasing.  This seems to be an issue
	with <application>KDE</application>, in particular.  One
	possible fix is to force the spacing for such fonts
	to be 100. Add these 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>After editing
	<filename>local.conf</filename>, make certain to end the file
	with the <literal>&lt;/fontconfig&gt;</literal> tag.  Not
	doing this will cause changes to be ignored.</para>

      <para>Users can add personalized settings by creating their own
	<filename>~/.config/fontconfig/fonts.conf</filename>.  This
	file uses the same <acronym>XML</acronym> format described
	above.</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
	<filename>local.conf</filename>:</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 xml:id="x-xdm">
    <info>
      <title>The X Display Manager</title>

      <authorgroup>
	<author>
	  <personname>
	    <firstname>Seth</firstname>
	    <surname>Kingsley</surname>
	  </personname>
	  <contrib>Originally contributed by </contrib>
	</author>
      </authorgroup>
    </info>

    <indexterm><primary>X Display Manager</primary></indexterm>
    <para><application>&xorg;</application> provides an X Display
      Manager, <application>XDM</application>, which can be used for
      login session management.  <application>XDM</application>
      provides a graphical interface for choosing which display server
      to connect to and for entering authorization information such as
      a login and password combination.</para>

    <para>This section demonstrates how to configure the X Display
      Manager on &os;.  Some desktop environments provide their own
      graphical login manager.  Refer to <xref
	linkend="x11-wm-gnome"/> for instructions on how to configure
      the GNOME Display Manager and <xref linkend="x11-wm-kde"/> for
      instructions on how to configure the KDE Display Manager.</para>

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

      <para>To install <application>XDM</application>, use the
	<package>x11/xdm</package> package or port.  Once installed,
	<application>XDM</application> can be configured to run when
	the  machine boots up by editing this entry in
	<filename>/etc/ttys</filename>:</para>

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

      <para>Change the <literal>off</literal> to <literal>on</literal>
	and save the edit.  The <literal>ttyv8</literal> in this entry
	indicates that <application>XDM</application> will run on the
	ninth virtual terminal.</para>

      <para>The <application>XDM</application> configuration directory
	is located in <filename>/usr/local/etc/X11/xdm</filename>.
	This directory contains several files used to change the
	behavior and appearance of <application>XDM</application>, as
	well as a few scripts and programs used to set up the desktop
	when <application>XDM</application> is running.  <xref
	  linkend="xdm-config-files"/> summarizes the function of each
	of these files.  The exact syntax and usage of these files is
	described in &man.xdm.1;.</para>

      <table frame="none" pgwide="1" xml:id="xdm-config-files">
	<title>XDM Configuration Files</title>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>File</entry>
	      <entry>Description</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry><filename>Xaccess</filename></entry>
	      <entry>The protocol for connecting to
		<application>XDM</application> is called the X Display
		Manager Connection Protocol (<acronym>XDMCP</acronym>)
		This file is a client authorization ruleset for
		controlling <acronym>XDMCP</acronym> connections from
		remote machines.  By default, this file does not allow
		any remote clients to connect.</entry>
	    </row>

	    <row>
	      <entry><filename>Xresources</filename></entry>
	      <entry>This file controls the look and feel of the
		<application>XDM</application> display chooser and
		login screens.  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.  The format of this file is identical
		to the app-defaults file described in the
		<application>&xorg;</application>
		documentation.</entry>
	    </row>

	    <row>
	      <entry><filename>Xservers</filename></entry>
	      <entry>The list of local and remote displays the chooser
		should provide as login choices.</entry>
	    </row>

	    <row>
	      <entry><filename>Xsession</filename></entry>
	      <entry>Default session script for logins which is run by
		<application>XDM</application> after a user has logged
		in.  This points to a customized session
		script in <filename>~/.xsession</filename>.</entry>
	    </row>

	    <row>
	      <entry><filename>Xsetup_</filename>*</entry>
	      <entry>Script to automatically launch applications
		before displaying the chooser or login interfaces.
		There is a script for each display being used, named
		<filename>Xsetup_*</filename>, where
		<literal>*</literal> is the local display number.
		Typically these scripts run one or two programs in the
		background such as
		<command>xconsole</command>.</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>Contains errors generated by the server program.
		If a display that <application>XDM</application> is
		trying to start hangs, look at this file for error
		messages.  These messages are also written to the
		user's <filename>~/.xsession-errors</filename> on a
		per-session basis.</entry>
	    </row>

	    <row>
	      <entry><filename>xdm-pid</filename></entry>
	      <entry>The running process <acronym>ID</acronym> of
		<application>XDM</application>.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>
    </sect2>

    <sect2>
      <title>Configuring Remote Access</title>

      <para>By default, only users on the same system can login using
	<application>XDM</application>.  To enable users on other
	systems to connect to the display server, edit the access
	control rules and enable the connection listener.</para>

      <para>To configure <application>XDM</application> to listen for
	any remote connection, comment out the
	<literal>DisplayManager.requestPort</literal> line in
	<filename>/usr/local/etc/X11/xdm/xdm-config</filename> by
	putting a <literal>!</literal> in front of it:</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>Save the edits and restart <application>XDM</application>.
	To restrict remote access, look at the example entries in
	<filename>/usr/local/etc/X11/xdm/Xaccess</filename> and refer
	to &man.xdm.1; for further information.</para>
    </sect2>
  </sect1>

  <sect1 xml:id="x11-wm">
    <info>
      <title>Desktop Environments</title>

      <authorgroup>
	<author>
	  <personname>
	    <firstname>Valentino</firstname>
	    <surname>Vaschetto</surname>
	  </personname>
	  <contrib>Contributed by </contrib>
	   <!-- in June 2001 -->
	</author>
      </authorgroup>
    </info>

    <para>This section describes how to install three popular desktop
      environments on a &os; system.  A desktop environment can range
      from a simple window manager to a complete suite of desktop
      applications.  Over a hundred desktop environments are available
      in the <filename>x11-wm</filename> category of the Ports
      Collection.</para>

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

      <indexterm><primary>GNOME</primary></indexterm>
      <para><application>GNOME</application> is a user-friendly
	desktop environment.  It includes a panel for starting
	applications and displaying status, a desktop, a set of tools
	and applications, and a set of conventions that make it easy
	for applications to cooperate and be consistent with each
	other.  More information regarding
	<application>GNOME</application> on &os; can be found at <link
	  xlink:href="https://www.FreeBSD.org/gnome">https://www.FreeBSD.org/gnome</link>.
	That web site contains additional documentation about
	installing, configuring, and managing
	<application>GNOME</application> on &os;.</para>

      <para>This desktop environment can be installed from a
	package:</para>

      <screen>&prompt.root; <userinput>pkg install gnome3</userinput></screen>

      <para>To instead build <application>GNOME</application> from
	ports, use the following command.
	<application>GNOME</application> is a large application and
	will take some time to compile, even on a fast
	computer.</para>

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

      <para><application>GNOME</application>
	requires <filename>/proc</filename> to be mounted.  Add this
	line to <filename>/etc/fstab</filename> to mount this file
	system automatically during system startup:</para>

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

      <para><application>GNOME</application> uses
	<application>D-Bus</application> and
	<application>HAL</application> for a message bus and hardware
	abstraction.  These applications are automatically installed
	as dependencies of <application>GNOME</application>.  Enable
	them in <filename>/etc/rc.conf</filename> so they will be
	started when the system boots:</para>

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

      <para>After installation,
	configure <application>&xorg;</application> to start
	<application>GNOME</application>.  The easiest way to do this
	is to enable the GNOME Display Manager,
	<application>GDM</application>, which is installed as part of
	the <application>GNOME</application> package or port.  It can
	be enabled by adding this line to
	<filename>/etc/rc.conf</filename>:</para>

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

      <para>It is often desirable to also start all
	<application>GNOME</application> services.  To achieve this,
	add a second line to <filename>/etc/rc.conf</filename>:</para>

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

      <para><application>GDM</application> will start
	automatically when the system boots.</para>

      <para>A second method for starting
	<application>GNOME</application> is to type
	<command>startx</command> from the command-line after
	configuring <filename>~/.xinitrc</filename>.  If this file
	already exists, replace the line that starts the current
	window manager with one that starts
	<filename>/usr/local/bin/gnome-session</filename>.  If this
	file does not exist, create it with this command:</para>

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

      <para>A third method is to use <application>XDM</application> as
	the display manager.  In this case, create an executable
	<filename>~/.xsession</filename>:</para>

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

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

      <indexterm><primary>KDE</primary></indexterm>

      <para><application>KDE</application> is another easy-to-use
	desktop environment.  This desktop provides a suite of
	applications with a consistent look and feel, a standardized
	menu and toolbars, keybindings, color-schemes,
	internationalization, and a centralized, dialog-driven desktop
	configuration.  More information on
	<application>KDE</application> can be found at <link
	  xlink:href="http://www.kde.org/">http://www.kde.org/</link>.
	For &os;-specific information, consult <link
	  xlink:href="http://freebsd.kde.org/">http://freebsd.kde.org</link>.</para>

      <para>To install the <application>KDE</application> package,
	type:</para>

      <screen>&prompt.root; <userinput>pkg install x11/kde4</userinput></screen>

      <para>To instead build the <application>KDE</application> port,
	use the following command.  Installing the port will provide a
	menu for selecting which components to install.
	<application>KDE</application> is a large application and will
	take some time to compile, even on a fast computer.</para>

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

      <indexterm>
	<primary>KDE</primary>
	<secondary>display manager</secondary>
      </indexterm>

      <para><application>KDE</application> requires
	<filename>/proc</filename> to be mounted.  Add this line to
	<filename>/etc/fstab</filename> to mount this file system
	automatically during system startup:</para>

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

      <para><application>KDE</application> uses
	<application>D-Bus</application> and
	<application>HAL</application> for a message bus and hardware
	abstraction.  These applications are automatically installed
	as dependencies of <application>KDE</application>.  Enable
	them in <filename>/etc/rc.conf</filename> so they will be
	started when the system boots:</para>

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

      <para>The installation of <application>KDE</application>
	includes the KDE Display Manager,
	<application>KDM</application>.  To enable this display
	manager, add this line to
	<filename>/etc/rc.conf</filename>:</para>

      <programlisting>kdm4_enable="YES"</programlisting>

      <para>A second method for launching
	<application>KDE</application> is to type
	<command>startx</command> from the command line.  For this to
	work, the following line is needed in
	<filename>~/.xinitrc</filename>:</para>

      <programlisting>exec /usr/local/bin/startkde</programlisting>

      <para>A third method for starting <application>KDE</application>
	is through <application>XDM</application>.  To do so, create
	an executable <filename>~/.xsession</filename> as
	follows:</para>

      <screen>&prompt.user; <userinput>echo "exec /usr/local/bin/startkde" &gt; ~/.xsession</userinput></screen>

      <para>Once <application>KDE</application> is started, refer to
	its built-in help system for more information on how to use
	its various menus and applications.</para>
    </sect2>

    <sect2 xml:id="x11-wm-xfce">
      <title>Xfce</title>

      <para><application>Xfce</application> is a desktop environment
	based on the GTK+ toolkit used by
	<application>GNOME</application>.  However, it is more
	lightweight and provides a simple, efficient, easy-to-use
	desktop.  It is fully configurable, has a main panel with
	menus, applets, and application launchers, provides a file
	manager and sound manager, and is themeable.  Since it is
	fast, light, and efficient, it is ideal for older or slower
	machines with memory limitations.  More information on
	<application>Xfce</application> can be found at <link
	  xlink:href="http://www.xfce.org/">http://www.xfce.org</link>.</para>

      <para>To install the <application>Xfce</application>
	package:</para>

      <screen>&prompt.root; <userinput>pkg install xfce</userinput></screen>

      <para>Alternatively, to build the port:</para>

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

      <para><application>Xfce</application> uses
	<application>D-Bus</application> for a message bus.  This
	application is automatically installed as dependency of
	<application>Xfce</application>.  Enable it in
	<filename>/etc/rc.conf</filename> so it will be started when
	the system boots:</para>

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

      <para>Unlike <application>GNOME</application> or
	<application>KDE</application>,
	<application>Xfce</application> does not provide its own login
	manager.  In order to start <application>Xfce</application>
	from the command line by typing <command>startx</command>,
	first create <filename>~/.xinitrc</filename> with this
	command:</para>

      <screen>&prompt.user; <userinput>echo ". /usr/local/etc/xdg/xfce4/xinitrc" &gt; ~/.xinitrc</userinput></screen>

      <para>An alternate method is to use
	<application>XDM</application>.  To configure this method,
	create an executable <filename>~/.xsession</filename>:</para>

      <screen>&prompt.user; <userinput>echo ". /usr/local/etc/xdg/xfce4/xinitrc" &gt; ~/.xsession</userinput></screen>
    </sect2>
  </sect1>

  <sect1 xml:id="x-compiz-fusion">
    <title>Installing Compiz Fusion</title>

    <para>One way to make using a desktop
      computer more pleasant is with nice 3D effects.</para>

    <para>Installing the <application>Compiz&nbsp;Fusion</application>
      package is easy, but configuring it requires a few steps that
      are not described in the port's documentation.</para>

    <sect2 xml:id="x-compiz-video-card">
      <title>Setting up the &os; nVidia Driver</title>

      <para>Desktop effects can cause quite a load on the graphics
	card.  For an nVidia-based graphics card, the proprietary
	driver is required for good performance.  Users of other
	graphics cards can skip this section and continue with the
	<filename>xorg.conf</filename> configuration.</para>

      <para>To determine which nVidia driver is needed see the <link
	  xlink:href="&url.books.faq;/x.html#idp59950544">FAQ question
	  on the subject</link>.</para>

      <para>Having determined the correct driver to use for your card,
	installation is as simple as installing any other
	package.</para>

      <para>For example, to install the latest driver:</para>

      <screen>&prompt.root; <userinput>pkg install x11/nvidia-driver</userinput></screen>

      <para>The driver will create a kernel module, which needs to be
	loaded at system startup.  Add the following line to
	<filename>/boot/loader.conf</filename>:</para>

      <programlisting>nvidia_load="YES"</programlisting>

      <note>
	<para>To immediately load the kernel module into the running
	  kernel by issuing a command like <command>kldload
	    nvidia</command>, however it has been noted that the some
	  versions of <application>&xorg;</application> will not
	  function properly if the driver is not loaded at boot time.
	  After editing <filename>/boot/loader.conf</filename>, a
	  reboot is recommended.</para>
      </note>

      <para>With the kernel module loaded, you normally only need to
	change a single line in <filename>xorg.conf</filename>
	to enable the proprietary driver:</para>

      <para>Find the following line in
	<filename>/etc/X11/xorg.conf</filename>:</para>

      <programlisting>Driver      "nv"</programlisting>

      <para>and change it to:</para>

      <programlisting>Driver      "nvidia"</programlisting>

      <para>Start the GUI as usual, and you should be greeted by the
	nVidia splash.  Everything should work as usual.</para>
    </sect2>

    <sect2 xml:id="xorg-configuration">
      <title>Configuring xorg.conf for Desktop Effects</title>

      <para>To enable <application>Compiz&nbsp;Fusion</application>,
	<filename>/etc/X11/xorg.conf</filename> needs to be
	modified:</para>

      <para>Add the following section to enable composite
	effects:</para>

      <programlisting>Section "Extensions"
    Option         "Composite" "Enable"
EndSection</programlisting>

      <para>Locate the <quote>Screen</quote> section which should look
	similar to the one below:</para>

      <programlisting>Section "Screen"
    Identifier     "Screen0"
    Device         "Card0"
    Monitor        "Monitor0"
    ...</programlisting>

      <para>and add the following two lines (after
	<quote>Monitor</quote> will do):</para>

      <programlisting>DefaultDepth    24
Option         "AddARGBGLXVisuals" "True"</programlisting>

      <para>Locate the <quote>Subsection</quote> that refers to the
	screen resolution that you wish to use.  For example, if you
	wish to use 1280x1024, locate the section that follows.  If
	the desired resolution does not appear in any subsection, you
	may add the relevant entry by hand:</para>

      <programlisting>SubSection     "Display"
    Viewport    0 0
    Modes      "1280x1024"
EndSubSection</programlisting>

      <para>A color depth of 24&nbsp;bits is needed for desktop
	composition, change the above subsection to:</para>

      <programlisting>SubSection     "Display"
    Viewport    0 0
    Depth       24
    Modes      "1280x1024"
EndSubSection</programlisting>

      <para>Finally, confirm that the <quote>glx</quote> and
	<quote>extmod</quote> modules are loaded in the
	<quote>Module</quote> section:</para>

      <programlisting>Section "Module"
    Load           "extmod"
    Load           "glx"
    ...</programlisting>

      <para>The preceding can be done automatically with
	<package>x11/nvidia-xconfig</package> by running (as
	root):</para>

      <screen>&prompt.root; <userinput>nvidia-xconfig --add-argb-glx-visuals</userinput>
&prompt.root; <userinput>nvidia-xconfig --composite</userinput>
&prompt.root; <userinput>nvidia-xconfig --depth=24</userinput></screen>
    </sect2>

    <sect2 xml:id="compiz-fusion">
      <title>Installing and Configuring Compiz&nbsp;Fusion</title>

      <para>Installing <application>Compiz&nbsp;Fusion</application>
	is as simple as any other package:</para>

      <screen>&prompt.root; <userinput>pkg install x11-wm/compiz-fusion</userinput></screen>

      <para>When the installation is finished, start your graphic
	desktop and at a terminal, enter the following commands (as a
	normal user):</para>

      <screen>&prompt.user; <userinput>compiz --replace --sm-disable --ignore-desktop-hints ccp &amp;</userinput>
&prompt.user; <userinput>emerald --replace &amp;</userinput></screen>

      <para>Your screen will flicker for a few seconds, as your window
	manager (e.g. <application>Metacity</application> if you are
	using <application>GNOME</application>) is replaced by
	<application>Compiz&nbsp;Fusion</application>.
	<application>Emerald</application> takes care of the window
	decorations (i.e. close, minimize, maximize buttons, title
	bars and so on).</para>

      <para>You may convert this to a trivial script and have it run
	at startup automatically (e.g. by adding to
	<quote>Sessions</quote> in a <application>GNOME</application>
	desktop):</para>

      <programlisting>#! /bin/sh
compiz --replace --sm-disable --ignore-desktop-hints ccp &amp;
emerald --replace &amp;</programlisting>

      <para>Save this in your home directory as, for example,
	<filename>start-compiz</filename> and make it
	executable:</para>

      <screen>&prompt.user; <userinput>chmod +x ~/start-compiz</userinput></screen>

      <para>Then use the GUI to add it to <guimenuitem>Startup
	  Programs</guimenuitem> (located in
	<guimenuitem>System</guimenuitem>,
	<guimenuitem>Preferences</guimenuitem>,
	<guimenuitem>Sessions</guimenuitem> on a
	<application>GNOME</application> desktop).</para>

      <para>To actually select all the desired effects and their
	settings, execute (again as a normal user) the
	<application>Compiz&nbsp;Config&nbsp;Settings&nbsp;Manager</application>:</para>

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

      <note>
	<para>In <application>GNOME</application>, this can also be
	  found in the <guimenuitem>System</guimenuitem>,
	  <guimenuitem>Preferences</guimenuitem> menu.</para>
      </note>

      <para>If you have selected <quote>gconf support</quote> during
	the build, you will also be able to view these settings using
	<command>gconf-editor</command> under
	<literal>apps/compiz</literal>.</para>
    </sect2>
  </sect1>

  <sect1 xml:id="x11-understanding">

    <title>Troubleshooting</title>

    <para>If the mouse does not work, you will need to first configure
      it before proceeding.
      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>/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><filename>/usr/local/share/X11/xkb/rules/base.lst</filename>
	  lists the various keyboard, layouts and options
	  available.</para>
      </note>

      <indexterm><primary><application>&xorg;</application>
	  tuning</primary></indexterm>

      <para>The <filename>xorg.conf.new</filename> configuration file
	may now be tuned to taste.  Open the file in a text editor
	such as &man.emacs.1; or &man.ee.1;.  If the monitor is an
	older or unusual model that does not support autodetection of
	sync frequencies, those settings can be added to
	<filename>xorg.conf.new</filename> 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>Most monitors support sync frequency autodetection, making
	manual entry of these values unnecessary.  For the few
	monitors that do not support autodetection, avoid potential
	damage by only entering values provided by the
	manufacturer.</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
	  <application>&xorg;</application> log files, which contain
	  information on each device that the
	  <application>&xorg;</application> 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 <application>&xorg;</application> configuration
	process is now complete.  <application>&xorg;</application>
	may be now started with the &man.startx.1; utility.  The
	<application>&xorg;</application> server may also be started
	with the use of &man.xdm.1;.</para>

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

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

	<para>Configuration with &intel; i810 integrated chipsets
	  requires the <filename>agpgart</filename> AGP programming
	  interface for <application>&xorg;</application> 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>
      </sect2>

      <sect2>
	<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>
      </sect2>

      <sect2 xml:id="compiz-troubleshooting">
	<title>Troubleshooting Compiz&nbsp;Fusion</title>

	<qandaset>
	  <qandaentry>
	    <question xml:id="no-decorations">
	      <para>I have installed
		<application>Compiz&nbsp;Fusion</application>, and
		after running the commands you mention, my windows are
		left without title bars and buttons.  What is
		wrong?</para>
	    </question>

	    <answer>
	      <para>You are probably missing a setting in
		<filename>/etc/X11/xorg.conf</filename>.  Review this
		file carefully and check especially the
		<literal>DefaultDepth</literal> and
		<literal>AddARGBGLXVisuals</literal>
		directives.</para>
	    </answer>
	  </qandaentry>

	  <qandaentry>
	    <question xml:id="xorg-crash">
	      <para>When I run the command to start
		<application>Compiz&nbsp;Fusion</application>, the X
		server crashes and I am back at the console.  What is
		wrong?</para>
	    </question>

	    <answer>
	      <para>If you check
		<filename>/var/log/Xorg.0.log</filename>, you
		will probably find error messages during the X
		startup.  The most common would be:</para>

	      <screen>(EE) NVIDIA(0):     Failed to initialize the GLX module; please check in your X
(EE) NVIDIA(0):     log file that the GLX module has been loaded in your X
(EE) NVIDIA(0):     server, and that the module is the NVIDIA GLX module.  If
(EE) NVIDIA(0):     you continue to encounter problems, Please try
(EE) NVIDIA(0):     reinstalling the NVIDIA driver.</screen>

	    <para>This is usually the case when you upgrade
	      <application>&xorg;</application>.  You will need to
	      reinstall the <package>x11/nvidia-driver</package>
	      package so glx is built again.</para>
	  </answer>
	</qandaentry>
      </qandaset>
    </sect2>
  </sect1>
</chapter>