doc/zh_TW.Big5/books/handbook/x11/chapter.sgml
Chin-San Huang f793b41541 - MFen: 1.184 -> 1.186
Submitted by:		whsyu
Obtained from:		The FreeBSD Traditional Chinese Project
			https://opensvn.csie.org/traccgi/freebsddoc/wiki
2008-02-21 11:26:37 +00:00

1561 lines
62 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
The FreeBSD Documentation Project
$FreeBSD$
Original revision: 1.186
-->
<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>X Window 視窗系統</title>
<sect1 id="x11-synopsis">
<title>概述</title>
<para>FreeBSD 使用 X11 來提供使用者相當好用的 GUI 介面。
X11 是 X Window 系統,包括 <application>&xorg;</application>
以及 <application>&xfree86;</application> 實作的自由軟體版本
(以及其他未在本章有介紹的軟體)。 &os; 一直到 &os;&nbsp;5.2.1-RELEASE
都仍可在預設的安裝程式內去裝 <application>&xfree86;</application>
(由 The &xfree86; Project, Inc 發行的 X11 server)。
而 &os;&nbsp;5.3-RELEASE 起,預設的 X11 改為
<application>&xorg;</application>(由 X.Org 基金會所開發的
X11 server並採用與 &os; 相當類似的 license)。 此外,當然也有商業
X servers 的 &os; 版。</para>
<para>本章主要是介紹 X11 (主要著重於 <application>&xorg;</application>
&xorg.version; 版部分)的安裝與設定。 若欲瞭解
<application>&xfree86;</application> 的詳細資料(早期的 &os; 內,
<application>&xfree86;</application> 乃是預設的 X11 套件),請參閱舊版的
&os; Handbook網址為 <ulink url="http://docs.FreeBSD.org/doc/"></ulink>
。</para>
<para>欲知 X11 對於顯示方面硬體的支援情況,請參閱 <ulink
url="http://www.x.org/">&xorg;</ulink> 網站。</para>
<para>讀完這章,您將了解:</para>
<itemizedlist>
<listitem>
<para>X Window 系統的各組成部份,以及它們是如何相互運作。</para>
</listitem>
<listitem>
<para>如何安裝、設定 X11。</para>
</listitem>
<listitem>
<para>如何安裝並使用不同的 window managers。</para>
</listitem>
<listitem>
<para>如何在 X11 上使用 &truetype; 字型。</para>
</listitem>
<listitem>
<para>如何設定系統以使用圖形登入介面。
(<application>XDM</application>)</para>
</listitem>
</itemizedlist>
<para>在開始閱讀這章之前,您需要︰</para>
<itemizedlist>
<listitem><para>知道如何運用 ports、packages 來安裝軟體。
(<xref linkend="ports">)</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="x-understanding">
<title>瞭解 X 的世界</title>
<para>第一次接觸 X 的人,大概都會有些震撼,尤其是熟悉其他 GUI 介面(像是
&microsoft.windows; 或 &macos;)的使用者。</para>
<para>雖然 X 各元件的所有細節及運作方式,並不是必須要知道的。
但對它們有些基本概念會更容易上手。</para>
<sect2>
<title>為何叫做 X</title>
<para>X 並非 &unix; 上第一套視窗系統,但它卻是最廣為流傳運用。
原本的 X 研發團隊在研發 X 之前有開發另一套視窗系統。 那套系統叫做
<quote>W</quote>(取 <quote>Window</quote> 的第一個字)。
而 X 則是 W 之後的下一個羅馬字母。</para>
<para>X 亦被稱之為 <quote>X</quote>、<quote>X Window System</quote>、
<quote>X11</quote>,以及其他一些詞彙。 使用 <quote>X Windows</quote>
這字眼來稱呼 X11可能會讓有些人不爽這部分細節可參閱 &man.X.7;
說明。</para>
</sect2>
<sect2>
<title>X 的 Client/Server 架構</title>
<para>X 一開始是設計為網路架構環境,並採用
<quote>client-server</quote> 架構。</para>
<para>在 X 架構下,
<quote>X server</quote> 是在有鍵盤、螢幕、滑鼠的電腦上運作。
而 server 部份則是負責像是顯示部份的管理、
處理來自鍵盤、滑鼠及其他設備(比方像是以繪圖板來輸入、
或者是顯示到投影機)的輸入等等,
每個 X 程式(像是 <application>XTerm</application>,或
<application>&netscape;</application>)都是 <quote>client</quote>。
client 會傳訊息到 server 上,比如:<quote>Please draw a
window at these coordinates</quote>,接著 server 會傳回訊息,比如:
<quote>The user just clicked on the OK button</quote>。</para>
<para>在家庭或小辦公室環境,通常 X server 跟 X client
都是在同一台電腦上執行的。 然而,也可以在比較爛的桌機上執行 X server
並在比較強、比較貴的電腦上跑 X 程式(client)來做事情。
在這種場景X client 與 server 之間的溝通就需透過網路來進行。</para>
<para>這點可能會讓有些人產生困惑,因為 X 術語與他們原本的認知剛好相反。
他們原本以為 <quote>X server</quote> 是要在最強悍的機器上跑才行,而
<quote>X client</quote> 則是在他們桌機上面跑。 實際上卻不是這樣。</para>
<para>有點相當重要,請記住 X server 是在有接螢幕、鍵盤的機器上運作,
而 X client 則是顯示這些視窗的程式。</para>
<para>協定(protocol)內並無強制規定 client 以及 server
兩邊機器都得是同一作業系統,或者得是同型機器才可以。
換句話說,也可以在 &microsoft.windows; 或蘋果電腦(Apple)的 &macos;
上跑 X server而且可以透過許多免費或商業軟體完成這些安裝、設定。
</para>
</sect2>
<sect2>
<title>The Window Manager</title>
<para>X 設計哲學與 &unix; 設計哲學相當類似,都是
<quote>tools, not policy</quote>。 也就是說X
不會試圖強制規定某任務應該要如何完成,而是只提供使用者一些工具,
至於如何運用這些工具,則是使用者本身的事了。</para>
<para>X 延續這哲學,它並不規定:螢幕上的視窗該長什麼樣、要如何移動滑鼠指標、
該用什麼組合鍵來切換各視窗(比如:在 &microsoft.windows; 的
<keycombo action="simul">
<keycap>Alt</keycap>
<keycap>Tab</keycap>
</keycombo>鍵)、各視窗的標題列長相,以及是否該有關閉鈕等等。</para>
<para>事實上X 把這部分交給所謂的 <quote>Window Manager</quote> 來管理。
有一堆 window manager 程式,像是: <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> 等等。每一種 window manager
都提供不同的使用經驗; 有些還可使用 <quote>virtual desktops(虛擬桌面)
</quote>;有些則可自訂組合鍵來管理桌面;有些會有 <quote>Start(開始)
</quote>鈕或其他類似設計;有些則是 <quote>可更換佈景主題</quote>
可自行安裝新的佈景主題以更換外觀。 這些跟其他的
window manager 在 Ports Collection 內的
<filename>x11-wm</filename> 目錄內都有。</para>
<para>此外,<application>KDE</application> 及
<application>GNOME</application> 桌面環境則有其自屬並整合完整的
window manager。</para>
<para>每個 window manager 也各有其不同的設定機制;有些需手動寫設定檔,
而有的則可透過 GUI 工具來完成大部分的設定。舉個例子:
<application>Sawfish</application> 就有以 Lisp 語言寫的設定檔。
</para>
<note>
<title>Focus Policy</title>
<para>window manager 的另一特色就是負責滑鼠指標的
<quote>focus policy</quote>。 每一種視窗系統都需要選擇作用視窗的方式
,以接受鍵盤輸入,以及決定目前哪個視窗是處於使用中的狀態。</para>
<para>通常較為人熟悉的 focus policy 叫做 <quote>click-to-focus</quote>
這是 &microsoft.windows; 所採用的模式,也就是指標在該視窗按一下的話,
該視窗就會處於使用中的狀態。</para>
<para>X 並不支援一些特殊的 focus policy。 換句話說window manager
會控制哪個視窗在何時是作用中。 不同的 window manager
有不同的支援方式。 但它們都支援 click-to-focus
而且大多數都有支援多種方式。</para>
<para>以下是目前最流行的 focus policy</para>
<variablelist>
<varlistentry>
<term>focus-follows-mouse</term>
<listitem>
<para>滑鼠移到哪個視窗就是使用該視窗。
該視窗不一定位於其他視窗上面,
但只要把滑鼠移到該視窗就可以改變作用中的視窗,
而不需在它上面點擊。</para>
</listitem>
</varlistentry>
<varlistentry>
<term>sloppy-focus</term>
<listitem>
<para>該 policy 是針對 focus-follows-mouse 的小小延伸。
對於 focus-follows-mouse 而言,若把游標移到最初的視窗(或桌面)
那所有其他視窗都會處於非作用中,而且所有鍵盤輸入也會失效。
若是選用 sloppy-focus則只有在游標移到新視窗時
作用中的視窗才會變成新的,
而只離開目前作用中的視窗仍不會改變作用狀態。</para>
</listitem>
</varlistentry>
<varlistentry>
<term>click-to-focus</term>
<listitem>
<para>由游標點擊才會決定作用中的視窗。 並且該視窗會被
<quote>raised(凸顯)</quote> 到所有其他視窗之前,
即使游標移到其他視窗,所有的鍵盤輸入仍會由該視窗所接收。</para>
</listitem>
</varlistentry>
</variablelist>
<para>許多 window manager 也支援其他 policy與這些相比起來又有些不同
細節部分請參閱該 window manager 的文件說明。</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>安裝 X11</title>
<para><application>&xorg;</application> 是 &os; 預設的 X11 實作。
<application>&xorg;</application> 是由 X.Org 基金會所發行之開放源碼軟體
X Window 系統實作的 X server。 <application>&xorg;</application>
乃是以 <application>&xfree86&nbsp;4.4RC2</application> 以及 X11R6.6
為基礎所產生的。 目前 &os; Ports Collection 內的
<application>&xorg;</application> 版本為 &xorg.version;。</para>
<para>從 Ports Collection 來安裝 <application>&xorg;</application>
的安裝方式:</para>
<screen>&prompt.root; <userinput>cd /usr/ports/x11/xorg</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>
<note>
<para>若要編譯完整的 <application>&xorg;</application>
請先確認至少有 4&nbsp;GB 的磁碟空間。</para>
</note>
<para>此外 X11 也可直接透過 package 方式來安裝,可使用 &man.pkg.add.1;
來安裝編譯好的 X11 套件,記得在透過網路安裝時不要指定版本即可,
&man.pkg.add.1; 會自動抓該套件最新版的套件回來。</para>
<para>若要自動透過 package 方式來裝 <application>&xorg;</application>
,直接打下面這行即可:</para>
<screen>&prompt.root; <userinput>pkg_add -r xorg</userinput></screen>
<note><para>上面的例子會裝完整的 X11 套件,包括 server、client、字型等。
此外,還有其他的 X11 子套件可透過 package 或 port
方式來單獨安裝。</para></note>
<para>本章其餘部分將介紹如何設定 X11
以及如何打造高生產力的桌面環境。</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</title>
<indexterm><primary>&xorg;</primary></indexterm>
<indexterm><primary>X11</primary></indexterm>
<sect2>
<title>在開始之前</title>
<para>在開始設定 X11 之前,要先瞭解所要裝的機器資料為何:</para>
<itemizedlist>
<listitem><para>螢幕規格</para></listitem>
<listitem><para>顯示卡的晶片規格</para></listitem>
<listitem><para>顯示卡的記憶體容量</para></listitem>
</itemizedlist>
<indexterm><primary>horizontal scan rate</primary></indexterm>
<indexterm><primary>vertical scan rate</primary></indexterm>
<para>X11 會依螢幕規格來決定解析度以及更新頻率。
這些規格通常可從螢幕所附的文件或廠商網站上取得。
最重要的是要知道水平、垂直更新頻率為何。</para>
<para>而顯示卡晶片則決定 X11 要用哪一種驅動程式模組。
大多數的晶片都可以自動偵測,但最好還是要知道是何種晶片,
以免萬一自動偵測失敗。</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>設定 X11</title>
<para><application>&xorg;</application> 自 7.3
版起不再需任何設定檔,只要打下列即可:</para>
<screen>&prompt.user; <userinput>startx</userinput></screen>
<para>若這指令不行或預設設定無法使用,那麼就需要手動設定 X11。
設定 X11 需要幾個步驟,首先是以系統管理者帳號來建立初始設定檔:</para>
<screen>&prompt.root; <userinput>Xorg -configure</userinput></screen>
<para>這會在 <filename>/root</filename> 目錄內產生
<filename>xorg.conf.new</filename> 設定檔(無論是用 &man.su.1;
或直接登入為 root都會改變 root 預設的 <envar>$HOME</envar> 環境變數)。
X11 程式接著會偵測系統的顯示卡相關硬體,並將偵測到硬體訊息寫入設定檔,
以便載入正確的驅動程式。</para>
<para>下一步是測試現有的設定檔,以便確認 <application>&xorg;</application>
可以與顯示卡、螢幕相關硬體正確運作:</para>
<screen>&prompt.root; <userinput>Xorg -config xorg.conf.new</userinput></screen>
<para>若看得到一堆黑灰夾雜的網格畫面,以及 X 形的滑鼠游標,
那麼設定檔就是成功的。 要退出測試,只要同時按下
<keycombo action="simul">
<keycap>Ctrl</keycap>
<keycap>Alt</keycap>
<keycap>Backspace</keycap>
</keycombo> 即可。</para>
<note><para>若滑鼠不正確運作,那麼需要先對其作設定。 請參閱
&os; 安裝一章中的 <xref linkend="mouse"> 說明。</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> 目前可透過 &man.startx.1;
來啟動之。
The X11 server may also be started with the use of
&man.xdm.1;.</para>
<note><para>There is also a graphical configuration tool,
&man.xorgcfg.1;, which comes with the
X11 distribution. It
allows you to interactively define your configuration by choosing
the appropriate drivers and settings. This program can be invoked from the console, by typing the command <command>xorgcfg -textmode</command>. For more details,
refer to the &man.xorgcfg.1; manual pages.</para>
<para>Alternatively, there is also a tool called &man.xorgconfig.1;.
This program is a console utility that is less user friendly,
but it may work in situations where the other tools do
not.</para></note>
</sect2>
<sect2>
<title>進階設定專欄</title>
<sect3>
<title>設定 &intel; i810 繪圖晶片組</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. 詳情請參閱 &man.agp.4; 說明。</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>為寬螢幕打造更舒適環境</title>
<indexterm><primary>widescreen flatpanel configuration</primary></indexterm>
<para>本節假設各位已經有些微進階設定的功力。
如果試著使用上述設定工具會有問題的話,請多利用相關 log 檔
(會記錄相關訊息)以便找出解法。
找尋解法過程中,可能會需要用到文字編輯器作為輔助。</para>
<para>目前的寬螢幕 (WSXGA, WSXGA+, WUXGA, WXGA, WXGA+ 等)
都有支援 16:10 及 10:9 比例,以及一些可能有問題的比例。
以下是一些常見的 16:10 螢幕解析度:</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>某方面而言,要增加這些解析度設定也是相當容易的,
只要在 <literal>Section "Screen"</literal> 內的
<literal>Mode</literal> 加上去就好,比如:</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> 可以透過 I2C/DDC
來得知該寬螢幕所支援的解析度等相關資訊,
因此就能正確偵測出該螢幕所能支援的頻率、解析度。</para>
<para>若驅動程式並未包括 <literal>ModeLine</literal> 訊息的話,
那麼就要為 <application>&xorg;</application> 做些設定才行。
我們可以透過 <filename>/var/log/Xorg.0.log</filename> 檔來取得
<literal>ModeLine</literal> 相關設定資料,即可讓螢幕正常顯示。
應該可以看到類似下面的訊息:</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>這些訊息被稱為 EDID 訊息。 可以藉由這些資料,
搭配下列的正確順序來產生 <literal>ModeLine</literal> 設定:</para>
<programlisting> ModeLine &lt;name&gt; &lt;clock&gt; &lt;4 horiz. timings&gt; &lt;4 vert. timings&gt;</programlisting>
<para>所以這個案例 <literal>Section "Monitor"</literal> 的
<literal>ModeLine</literal> 就會是像下面這樣:</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>這樣子就簡單完成了X 視窗就可以打造為新的寬螢幕環境囉。</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>在 X11 中使用字型</title>
<sect2 id="type1">
<title>Type1 規格的字型</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; 規格的字型</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 規格的字型</title>
<indexterm><primary>anti-aliased fonts</primary></indexterm>
<indexterm><primary>fonts</primary>
<secondary>anti-aliased</secondary></indexterm>
<para>Anti-aliasing has been available in X11 since
<application>&xfree86;</application> 4.0.2. However, font
configuration was cumbersome before the introduction of
<application>&xfree86;</application> 4.3.0.
Beginning with
<application>&xfree86;</application> 4.3.0, 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. Not
all applications are Xft-aware, but many have received Xft support.
Examples of Xft-aware applications include Qt 2.3 and higher (the
toolkit for the <application>KDE</application> desktop),
GTK+ 2.0 and higher (the toolkit for the
<application>GNOME</application> desktop), and
<application>Mozilla</application> 1.2 and higher.
</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 such as <application>Mozilla</application> 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>The default font set that comes with
X11 is not very
desirable when it comes to anti-aliasing. A much better
set of default fonts can be found in the
<filename role="package">x11-fonts/bitstream-vera</filename>
port. This port will install a
<filename>/usr/local/etc/fonts/local.conf</filename> file
if one does not exist already. If the file does exist,
the port will create a <filename>/usr/local/etc/fonts/local.conf-vera
</filename> file. Merge the contents of this file into
<filename>/usr/local/etc/fonts/local.conf</filename>, and the
Bitstream fonts will automatically replace the default
X11 Serif, Sans Serif, and Monospaced
fonts.</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>
<indexterm>
<primary>Mozilla</primary>
<secondary>disabling anti-aliased fonts</secondary>
</indexterm>
<para>Anti-aliasing should be enabled the next time the X
server is started. However, programs must know how to take
advantage of it. At present, the Qt toolkit does,
so the entire <application>KDE</application> environment can
use anti-aliased fonts.
GTK+ and
<application>GNOME</application> can also be made to use
anti-aliasing via the <quote>Font</quote> capplet (see <xref
linkend="x11-wm-gnome-antialias"> for details). By default,
<application>Mozilla</application> 1.2 and greater will
automatically use anti-aliasing. To disable this, rebuild
<application>Mozilla</application> with the
<makevar>-DWITHOUT_XFT</makevar> flag.</para>
</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>The <application>XDM</application> daemon program is
located 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 infomation.</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>桌面環境</title>
<para>本章會介紹在 FreeBSD 中的 X 裡頭,有哪些不同的桌面環境。
<quote>桌面環境</quote>範圍很廣,從簡單的 window manager 到
完整的桌面應用程式,例如 <application>KDE</application> 或 <application>GNOME</application>。
</para>
<sect2 id="x11-wm-gnome">
<title>GNOME</title>
<sect3 id="x11-wm-gnome-about">
<title>關於 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>可透過 package 或 Ports Collection 的方式來輕鬆安裝:</para>
<para>透過網路利用 package 安裝 <application>GNOME</application></para>
<screen>&prompt.root; <userinput>pkg_add -r gnome2</userinput></screen>
<para>從 ports tree 透過原始碼編譯安裝 <application>GNOME</application></para>
<screen>&prompt.root; <userinput>cd /usr/ports/x11/gnome2</userinput>
&prompt.root; <userinput>make install clean</userinput></screen>
<para>當 <application>GNOME</application> 安裝完成後,
必須告訴 X server 啟動 <application>GNOME</application> 而非原本的 window manager。</para>
<para>啟動 <application>GNOME</application> 最簡單的方法是利
用 <application>GDM</application>(GNOME Display Manager)。
<application>GDM</application>, which is installed as a part
of the <application>GNOME</application> desktop (but is
disabled by default), can be enabled by adding
<literal>gdm_enable="YES"</literal> to
<filename>/etc/rc.conf</filename>. Once you have rebooted,
<application>GNOME</application> will start automatically
once you log in &mdash; no further configuration is
necessary.</para>
<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>
<sect3 id="x11-wm-gnome-antialias">
<title>Anti-aliased Fonts with GNOME</title>
<indexterm><primary>GNOME</primary>
<secondary>anti-aliased fonts</secondary></indexterm>
<para>X11
supports anti-aliasing via its <quote>RENDER</quote> extension.
GTK+ 2.0 and greater (the toolkit used by
<application>GNOME</application>) can make use of this
functionality. Configuring anti-aliasing is described in
<xref linkend="antialias">. So, with up-to-date software,
anti-aliasing is possible within the
<application>GNOME</application> desktop. Just go to
<menuchoice>
<guimenu>Applications</guimenu>
<guisubmenu>Desktop Preferences</guisubmenu>
<guimenuitem>Font</guimenuitem></menuchoice>, and select either
<guibutton>Best shapes</guibutton>,
<guibutton>Best contrast</guibutton>, or
<guibutton>Subpixel smoothing (LCDs)</guibutton>. For a
GTK+ application that is not part of the
<application>GNOME</application> desktop, set the
environment variable <varname>GDK_USE_XFT</varname> to
<literal>1</literal> before launching the program.</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>
</sect3>
<sect3 id="x11-wm-kde-install">
<title>安裝 KDE</title>
<para>如同 <application>GNOME</application> 或其他桌面管理軟體一樣,
也可以輕鬆透過 package 或 Ports Collection 來安裝:</para>
<para>To install the <application>KDE</application> package
from the network, simply type:</para>
<screen>&prompt.root; <userinput>pkg_add -r kde</userinput></screen>
<para>&man.pkg.add.1; will automatically fetch the latest version
of the application.</para>
<para>To build <application>KDE</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>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>
<screen>&prompt.user; <userinput>echo "exec 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>, the
<literal>ttyv8</literal> entry in <filename>/etc/ttys</filename>
has to be adapted. The line should look as follows:</para>
<programlisting>ttyv8 "/usr/local/bin/kdm -nodaemon" xterm on secure</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:
-->