Ken Tom Updated for X.Org's X11 server by Marc Fonvieille X Window 視窗系統 概述 FreeBSD 使用 X11 來提供使用者相當好用的 GUI 介面。 X11 是 X Window 系統,包括 &xorg; 以及 &xfree86; 實作的自由軟體版本 (以及其他未在本章有介紹的軟體)。 &os; 一直到 &os; 5.2.1-RELEASE 都仍可在預設的安裝程式內去裝 &xfree86; (由 The &xfree86; Project, Inc 發行的 X11 server)。 而 &os; 5.3-RELEASE 起,預設的 X11 改為 &xorg;(由 X.Org 基金會所開發的 X11 server,並採用與 &os; 相當類似的 license)。 此外,當然也有商業 X servers 的 &os; 版。 本章主要是介紹 X11 (主要著重於 &xorg; &xorg.version; 版部分)的安裝與設定。 若欲瞭解 &xfree86; 的詳細資料(早期的 &os; 內, &xfree86; 乃是預設的 X11 套件),請參閱舊版的 &os; Handbook,網址為 欲知 X11 對於顯示方面硬體的支援情況,請參閱 &xorg; 網站。 讀完這章,您將了解: X Window 系統的各組成部份,以及它們是如何相互運作。 如何安裝、設定 X11。 如何安裝並使用不同的 window managers。 如何在 X11 上使用 &truetype; 字型。 如何設定系統以使用圖形登入介面。 (XDM) 在開始閱讀這章之前,您需要︰ 知道如何運用 ports、packages 來安裝軟體。 () 瞭解 X 的世界 第一次接觸 X 的人,大概都會有些震撼,尤其是熟悉其他 GUI 介面(像是 µsoft.windows; 或 &macos;)的使用者。 雖然 X 各元件的所有細節及運作方式,並不是必須要知道的。 但對它們有些基本概念會更容易上手。 為何叫做 X? X 並非 &unix; 上第一套視窗系統,但它卻是最廣為流傳運用。 原本的 X 研發團隊在研發 X 之前有開發另一套視窗系統。 那套系統叫做 W(取 Window 的第一個字)。 而 X 則是 W 之後的下一個羅馬字母。 X 亦被稱之為 XX Window SystemX11,以及其他一些詞彙。 使用 X Windows 這字眼來稱呼 X11,可能會讓有些人不爽;這部分細節可參閱 &man.X.7; 說明。 X 的 Client/Server 架構 X 一開始是設計為網路架構環境,並採用 client-server 架構。 在 X 架構下, X server 是在有鍵盤、螢幕、滑鼠的電腦上運作。 而 server 部份則是負責像是顯示部份的管理、 處理來自鍵盤、滑鼠及其他設備(比方像是以繪圖板來輸入、 或者是顯示到投影機)的輸入等等, 每個 X 程式(像是 XTerm,或 &netscape;)都是 client。 client 會傳訊息到 server 上,比如:Please draw a window at these coordinates,接著 server 會傳回訊息,比如: The user just clicked on the OK button 在家庭或小辦公室環境,通常 X server 跟 X client 都是在同一台電腦上執行的。 然而,也可以在比較爛的桌機上執行 X server, 並在比較強、比較貴的電腦上跑 X 程式(client)來做事情。 在這種場景,X client 與 server 之間的溝通就需透過網路來進行。 這點可能會讓有些人產生困惑,因為 X 術語與他們原本的認知剛好相反。 他們原本以為 X server 是要在最強悍的機器上跑才行,而 X client 則是在他們桌機上面跑。 實際上卻不是這樣。 有點相當重要,請記住 X server 是在有接螢幕、鍵盤的機器上運作, 而 X client 則是顯示這些視窗的程式。 協定(protocol)內並無強制規定 client 以及 server 兩邊機器都得是同一作業系統,或者得是同型機器才可以。 換句話說,也可以在 µsoft.windows; 或蘋果電腦(Apple)的 &macos; 上跑 X server,而且可以透過許多免費或商業軟體完成這些安裝、設定。 The Window Manager X 設計哲學與 &unix; 設計哲學相當類似,都是 tools, not policy。 也就是說,X 不會試圖強制規定某任務應該要如何完成,而是只提供使用者一些工具, 至於如何運用這些工具,則是使用者本身的事了。 X 延續這哲學,它並不規定:螢幕上的視窗該長什麼樣、要如何移動滑鼠指標、 該用什麼組合鍵來切換各視窗(比如:在 µsoft.windows; 的 Alt Tab 鍵)、各視窗的標題列長相,以及是否該有關閉鈕等等。 事實上,X 把這部分交給所謂的 Window Manager 來管理。 有一堆 window manager 程式,像是: AfterStepBlackboxctwmEnlightenmentfvwmSawfishtwmWindow Maker 等等。每一種 window manager 都提供不同的使用經驗; 有些還可使用 virtual desktops(虛擬桌面) ;有些則可自訂組合鍵來管理桌面;有些會有 Start(開始) 鈕或其他類似設計;有些則是 可更換佈景主題, 可自行安裝新的佈景主題以更換外觀。 這些跟其他的 window manager 在 Ports Collection 內的 x11-wm 目錄內都有。 此外,KDEGNOME 桌面環境則有其自屬並整合完整的 window manager。 每個 window manager 也各有其不同的設定機制;有些需手動寫設定檔, 而有的則可透過 GUI 工具來完成大部分的設定。舉個例子: Sawfish 就有以 Lisp 語言寫的設定檔。 Focus Policy window manager 的另一特色就是負責滑鼠指標的 focus policy。 每一種視窗系統都需要選擇作用視窗的方式 ,以接受鍵盤輸入,以及決定目前哪個視窗是處於使用中的狀態。 通常較為人熟悉的 focus policy 叫做 click-to-focus, 這是 µsoft.windows; 所採用的模式,也就是指標在該視窗按一下的話, 該視窗就會處於使用中的狀態。 X 並不支援一些特殊的 focus policy。 換句話說,window manager 會控制哪個視窗在何時是作用中。 不同的 window manager 有不同的支援方式。 但它們都支援 click-to-focus, 而且大多數都有支援多種方式。 以下是目前最流行的 focus policy: focus-follows-mouse 滑鼠移到哪個視窗就是使用該視窗。 該視窗不一定位於其他視窗上面, 但只要把滑鼠移到該視窗就可以改變作用中的視窗, 而不需在它上面點擊。 sloppy-focus 該 policy 是針對 focus-follows-mouse 的小小延伸。 對於 focus-follows-mouse 而言,若把游標移到最初的視窗(或桌面), 那所有其他視窗都會處於非作用中,而且所有鍵盤輸入也會失效。 若是選用 sloppy-focus,則只有在游標移到新視窗時, 作用中的視窗才會變成新的, 而只離開目前作用中的視窗仍不會改變作用狀態。 click-to-focus 由游標點擊才會決定作用中的視窗。 並且該視窗會被 raised(凸顯) 到所有其他視窗之前, 即使游標移到其他視窗,所有的鍵盤輸入仍會由該視窗所接收。 許多 window manager 也支援其他 policy,與這些相比起來又有些不同, 細節部分請參閱該 window manager 的文件說明。 Widgets The X approach of providing tools and not policy extends to the widgets seen on screen in each application. Widget 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. µsoft.windows; calls these controls. µsoft.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. 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, &motif; (on which the widget set in µsoft.windows; was modeled, all bevelled edges and three shades of grey), OpenLook, and others. Most newer X applications today will use a modern-looking widget set, either Qt, used by KDE, or GTK+, used by the GNOME 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. 安裝 X11 &xorg; 是 &os; 預設的 X11 實作。 &xorg; 是由 X.Org 基金會所發行之開放源碼軟體 X Window 系統實作的 X server。 &xorg; 乃是以 &xfree86; 4.4RC2 以及 X11R6.6 為基礎所產生的。 目前 &os; Ports Collection 內的 &xorg; 版本為 &xorg.version;。 從 Ports Collection 來安裝 &xorg; 的安裝方式: &prompt.root; cd /usr/ports/x11/xorg &prompt.root; make install clean 若要編譯完整的 &xorg;, 請先確認至少有 4 GB 的磁碟空間。 此外 X11 也可直接透過 package 方式來安裝,可使用 &man.pkg.add.1; 來安裝編譯好的 X11 套件,記得在透過網路安裝時不要指定版本即可, &man.pkg.add.1; 會自動抓該套件最新版的套件回來。 若要自動透過 package 方式來裝 &xorg; ,直接打下面這行即可: &prompt.root; pkg_add -r xorg 上面的例子會裝完整的 X11 套件,包括 server、client、字型等。 此外,還有其他的 X11 子套件可透過 package 或 port 方式來單獨安裝。 本章其餘部分將介紹如何設定 X11, 以及如何打造高生產力的桌面環境。 Christopher Shumway Contributed by 設定 X11 &xorg; X11 在開始之前 在開始設定 X11 之前,要先瞭解所要裝的機器資料為何: 螢幕規格 顯示卡的晶片規格 顯示卡的記憶體容量 horizontal scan rate vertical scan rate X11 會依螢幕規格來決定解析度以及更新頻率。 這些規格通常可從螢幕所附的文件或廠商網站上取得。 最重要的是要知道水平、垂直更新頻率為何。 而顯示卡晶片則決定 X11 要用哪一種驅動程式模組。 大多數的晶片都可以自動偵測,但最好還是要知道是何種晶片, 以免萬一自動偵測失敗。 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. 設定 X11 &xorg; 自 7.3 版起不再需任何設定檔,只要打下列即可: &prompt.user; startx 若這指令不行或預設設定無法使用,那麼就需要手動設定 X11。 設定 X11 需要幾個步驟,首先是以系統管理者帳號來建立初始設定檔: &prompt.root; Xorg -configure 這會在 /root 目錄內產生 xorg.conf.new 設定檔(無論是用 &man.su.1; 或直接登入為 root,都會改變 root 預設的 $HOME 環境變數)。 X11 程式接著會偵測系統的顯示卡相關硬體,並將偵測到硬體訊息寫入設定檔, 以便載入正確的驅動程式。 下一步是測試現有的設定檔,以便確認 &xorg; 可以與顯示卡、螢幕相關硬體正確運作: &prompt.root; Xorg -config xorg.conf.new 若看得到一堆黑灰夾雜的網格畫面,以及 X 形的滑鼠游標, 那麼設定檔就是成功的。 要退出測試,只要同時按下 Ctrl Alt Backspace 即可。 若滑鼠不正確運作,那麼需要先對其作設定。 請參閱 &os; 安裝一章中的 說明。 X11 tuning Next, tune the xorg.conf.new 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 xorg.conf.new file under the "Monitor" section: Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "Monitor Model" HorizSync 30-107 VertRefresh 48-120 EndSection The HorizSync and VertRefresh 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 HorizSync keyword and the vertical synchronization rate after the VertRefresh keyword. In the example above the target monitor's rates were entered. 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: Option "DPMS" xorg.conf While the xorg.conf.new configuration file is still open in an editor, select the default resolution and color depth desired. This is defined in the "Screen" section: Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 Modes "1024x768" EndSubSection EndSection The DefaultDepth keyword describes the color depth to run at by default. This can be overridden with the command line switch to &man.Xorg.1;. The Modes 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. Finally, write the configuration file and test it using the test mode given above. 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. &xorg; log file names are in the format of /var/log/Xorg.0.log. The exact name of the log can vary from Xorg.0.log to Xorg.8.log and so forth. 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 /etc/X11/xorg.conf or /usr/local/etc/X11/xorg.conf. &prompt.root; cp xorg.conf.new /etc/X11/xorg.conf The X11 configuration process is now complete. &xorg; 目前可透過 &man.startx.1; 來啟動之。 The X11 server may also be started with the use of &man.xdm.1;. 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 xorgcfg -textmode. For more details, refer to the &man.xorgcfg.1; manual pages. 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. 進階設定專欄 設定 &intel; i810 繪圖晶片組 Intel i810 graphic chipset Configuration with &intel; i810 integrated chipsets requires the agpgart AGP programming interface for X11 to drive the card. 詳情請參閱 &man.agp.4; 說明。 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 /boot/loader.conf. 為寬螢幕打造更舒適環境 widescreen flatpanel configuration 本節假設各位已經有些微進階設定的功力。 如果試著使用上述設定工具會有問題的話,請多利用相關 log 檔 (會記錄相關訊息)以便找出解法。 找尋解法過程中,可能會需要用到文字編輯器作為輔助。 目前的寬螢幕 (WSXGA, WSXGA+, WUXGA, WXGA, WXGA+ 等) 都有支援 16:10 及 10:9 比例,以及一些可能有問題的比例。 以下是一些常見的 16:10 螢幕解析度: 2560x1600 1920x1200 1680x1050 1440x900 1280x800 某方面而言,要增加這些解析度設定也是相當容易的, 只要在 Section "Screen" 內的 Mode 加上去就好,比如: Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 Modes "1680x1050" EndSubSection EndSection &xorg; 可以透過 I2C/DDC 來得知該寬螢幕所支援的解析度等相關資訊, 因此就能正確偵測出該螢幕所能支援的頻率、解析度。 若驅動程式並未包括 ModeLine 訊息的話, 那麼就要為 &xorg; 做些設定才行。 我們可以透過 /var/log/Xorg.0.log 檔來取得 ModeLine 相關設定資料,即可讓螢幕正常顯示。 應該可以看到類似下面的訊息: (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 這些訊息被稱為 EDID 訊息。 可以藉由這些資料, 搭配下列的正確順序來產生 ModeLine 設定: ModeLine <name> <clock> <4 horiz. timings> <4 vert. timings> 所以這個案例 Section "Monitor"ModeLine 就會是像下面這樣: Section "Monitor" Identifier "Monitor1" VendorName "Bigname" ModelName "BestModel" ModeLine "1680x1050" 146.2 1680 1784 1960 2240 1050 1053 1059 1089 Option "DPMS" EndSection 這樣子就簡單完成了,X 視窗就可以打造為新的寬螢幕環境囉。 Murray Stokely Contributed by 在 X11 中使用字型 Type1 規格的字型 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 &netscape; 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 (x11-fonts/urwfonts) includes high quality versions of standard type1 fonts (Times Roman, Helvetica, Palatino and others). The Freefonts collection (x11-fonts/freefonts) includes many more fonts, but most of them are intended for use in graphics software such as the Gimp, 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 section on &truetype; fonts. To install the above Type1 font collections from the ports collection, run the following commands: &prompt.root; cd /usr/ports/x11-fonts/urwfonts &prompt.root; make install clean 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 (/etc/X11/xorg.conf), which reads: FontPath "/usr/local/lib/X11/fonts/URW/" Alternatively, at the command line in the X session run: &prompt.user; xset fp+ /usr/local/lib/X11/fonts/URW &prompt.user; xset fp rehash This will work but will be lost when the X session is closed, unless it is added to the startup file (~/.xinitrc for a normal startx session, or ~/.xsession when logging in through a graphical login manager like XDM). A third way is to use the new /usr/local/etc/fonts/local.conf file: see the section on anti-aliasing. &truetype; 規格的字型 TrueType Fonts fonts TrueType &xorg; 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 "Module" section of the /etc/X11/xorg.conf file. Load "freetype" Now make a directory for the &truetype; fonts (for example, /usr/local/lib/X11/fonts/TrueType) 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 ttmkfdir to create a fonts.dir file, so that the X font renderer knows that these new files have been installed. ttmkfdir is available from the FreeBSD Ports Collection as x11-fonts/ttmkfdir. &prompt.root; cd /usr/local/lib/X11/fonts/TrueType &prompt.root; ttmkfdir -o fonts.dir Now add the &truetype; directory to the font path. This is just the same as described above for Type1 fonts, that is, use &prompt.user; xset fp+ /usr/local/lib/X11/fonts/TrueType &prompt.user; xset fp rehash or add a FontPath line to the xorg.conf file. That's it. Now &netscape;, Gimp, &staroffice;, 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 &staroffice;) will look much better now. Joe Marcus Clarke Updated by Anti-Aliased 規格的字型 anti-aliased fonts fonts anti-aliased Anti-aliasing has been available in X11 since &xfree86; 4.0.2. However, font configuration was cumbersome before the introduction of &xfree86; 4.3.0. Beginning with &xfree86; 4.3.0, all fonts in X11 that are found in /usr/local/lib/X11/fonts/ and ~/.fonts/ 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 KDE desktop), GTK+ 2.0 and higher (the toolkit for the GNOME desktop), and Mozilla 1.2 and higher. In order to control which fonts are anti-aliased, or to configure anti-aliasing properties, create (or edit, if it already exists) the file /usr/local/etc/fonts/local.conf. 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;. XML 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 <fontconfig> tag: <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> As previously stated, all fonts in /usr/local/lib/X11/fonts/ as well as ~/.fonts/ 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 /usr/local/etc/fonts/local.conf: <dir>/path/to/my/fonts</dir> After adding new fonts, and especially new font directories, you should run the following command to rebuild the font caches: &prompt.root; fc-cache -f Anti-aliasing makes borders slightly fuzzy, which makes very small text more readable and removes staircases 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: <match target="font"> <test name="size" compare="less"> <double>14</double> </test> <edit name="antialias" mode="assign"> <bool>false</bool> </edit> </match> <match target="font"> <test name="pixelsize" compare="less" qual="any"> <double>14</double> </test> <edit mode="assign" name="antialias"> <bool>false</bool> </edit> </match> fonts spacing Spacing for some monospaced fonts may also be inappropriate with anti-aliasing. This seems to be an issue with KDE, in particular. One possible fix for this is to force the spacing for such fonts to be 100. Add the following lines: <match target="pattern" name="family"> <test qual="any" name="family"> <string>fixed</string> </test> <edit name="family" mode="assign"> <string>mono</string> </edit> </match> <match target="pattern" name="family"> <test qual="any" name="family"> <string>console</string> </test> <edit name="family" mode="assign"> <string>mono</string> </edit> </match> (this aliases the other common names for fixed fonts as "mono"), and then add: <match target="pattern" name="family"> <test qual="any" name="family"> <string>mono</string> </test> <edit name="spacing" mode="assign"> <int>100</int> </edit> </match> 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 Mozilla to crash. To avoid this, consider adding the following to local.conf: <match target="pattern" name="family"> <test qual="any" name="family"> <string>Helvetica</string> </test> <edit name="family" mode="assign"> <string>sans-serif</string> </edit> </match> Once you have finished editing local.conf make sure you end the file with the </fontconfig> tag. Not doing this will cause your changes to be ignored. 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 x11-fonts/bitstream-vera port. This port will install a /usr/local/etc/fonts/local.conf file if one does not exist already. If the file does exist, the port will create a /usr/local/etc/fonts/local.conf-vera file. Merge the contents of this file into /usr/local/etc/fonts/local.conf, and the Bitstream fonts will automatically replace the default X11 Serif, Sans Serif, and Monospaced fonts. Finally, users can add their own settings via their personal .fonts.conf files. To do this, each user should simply create a ~/.fonts.conf. This file must also be in XML format. LCD screen Fonts LCD screen 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 local.conf file: <match target="font"> <test qual="all" name="rgba"> <const>unknown</const> </test> <edit name="rgba" mode="assign"> <const>rgb</const> </edit> </match> Depending on the sort of display, rgb may need to be changed to bgr, vrgb or vbgr: experiment and see which works best. Mozilla disabling anti-aliased fonts 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 KDE environment can use anti-aliased fonts. GTK+ and GNOME can also be made to use anti-aliasing via the Font capplet (see for details). By default, Mozilla 1.2 and greater will automatically use anti-aliasing. To disable this, rebuild Mozilla with the -DWITHOUT_XFT flag. Seth Kingsley Contributed by The X Display Manager Overview X Display Manager The X Display Manager (XDM) 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 X Terminals, 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. XDM provides a graphical interface for choosing which display server to connect to, and entering authorization information such as a login and password combination. Think of XDM as providing the same functionality to the user as the &man.getty.8; utility (see 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). XDM then waits for this program to exit, signaling that the user is done and should be logged out of the display. At this point, XDM can display the login and display chooser screens for the next user to login. Using XDM The XDM daemon program is located in /usr/local/bin/xdm. This program can be run at any time as root and it will start managing the X display on the local machine. If XDM is to be run every time the machine boots up, a convenient way to do this is by adding an entry to /etc/ttys. For more information about the format and usage of this file, see . There is a line in the default /etc/ttys file for running the XDM daemon on a virtual terminal: ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure By default this entry is disabled; in order to enable it change field 5 from off to on and restart &man.init.8; using the directions in . The first field, the name of the terminal this program will manage, is ttyv8. This means that XDM will start running on the 9th virtual terminal. Configuring XDM The XDM configuration directory is located in /usr/local/lib/X11/xdm. In this directory there are several files used to change the behavior and appearance of XDM. Typically these files will be found: File Description Xaccess Client authorization ruleset. Xresources Default X resource values. Xservers List of remote and local displays to manage. Xsession Default session script for logins. Xsetup_* Script to launch applications before the login interface. xdm-config Global configuration for all displays running on this machine. xdm-errors Errors generated by the server program. xdm-pid The process ID of the currently running XDM. Also in this directory are a few scripts and programs used to set up the desktop when XDM 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;. The default configuration is a simple rectangular login window with the hostname of the machine displayed at the top in a large font and Login: and Password: prompts below. This is a good starting point for changing the look and feel of XDM screens. Xaccess The protocol for connecting to XDM-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 xdm-config is changed to listen for remote connections. By default, it does not allow any clients to connect. Xresources 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. Xservers This is a list of the remote displays the chooser should provide as choices. Xsession This is the default session script for XDM to run after a user has logged in. Normally each user will have a customized session script in ~/.xsession that overrides this script. Xsetup_* These will be run automatically before displaying the chooser or login interfaces. There is a script for each display being used, named Xsetup_ followed by the local display number (for instance Xsetup_0). Typically these scripts will run one or two programs in the background such as xconsole. xdm-config This contains settings in the form of app-defaults that are applicable to every display that this installation manages. xdm-errors This contains the output of the X servers that XDM is trying to run. If a display that XDM 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 ~/.xsession-errors file on a per-session basis. Running a Network Display Server 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 XDM listen for connections, first comment out a line in the xdm-config file: ! 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 and then restart XDM. Remember that comments in app-defaults files begin with a ! character, not the usual #. More strict access controls may be desired — look at the example entries in Xaccess, and refer to the &man.xdm.1; manual page for further infomation. Replacements for XDM Several replacements for the default XDM program exist. One of them, kdm (bundled with KDE) is described later in this chapter. The kdm 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. Valentino Vaschetto Contributed by 桌面環境 本章會介紹在 FreeBSD 中的 X 裡頭,有哪些不同的桌面環境。 桌面環境範圍很廣,從簡單的 window manager 到 完整的桌面應用程式,例如 KDEGNOME GNOME 關於 GNOME GNOME GNOME is a user-friendly desktop environment that enables users to easily use and configure their computers. GNOME 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 GNOME provides. More information regarding GNOME on FreeBSD can be found on the FreeBSD GNOME Project's web site. The web site also contains fairly comprehensive FAQs about installing, configuring, and managing GNOME. Installing GNOME 可透過 package 或 Ports Collection 的方式來輕鬆安裝: 透過網路利用 package 安裝 GNOME &prompt.root; pkg_add -r gnome2 從 ports tree 透過原始碼編譯安裝 GNOME &prompt.root; cd /usr/ports/x11/gnome2 &prompt.root; make install clean GNOME 安裝完成後, 必須告訴 X server 啟動 GNOME 而非原本的 window manager。 啟動 GNOME 最簡單的方法是利 用 GDM(GNOME Display Manager)。 GDM, which is installed as a part of the GNOME desktop (but is disabled by default), can be enabled by adding gdm_enable="YES" to /etc/rc.conf. Once you have rebooted, GNOME will start automatically once you log in — no further configuration is necessary. GNOME may also be started from the command-line by properly configuring a file named .xinitrc. If a custom .xinitrc is already in place, simply replace the line that starts the current window manager with one that starts /usr/local/bin/gnome-session instead. If nothing special has been done to the configuration file, then it is enough simply to type: &prompt.user; echo "/usr/local/bin/gnome-session" > ~/.xinitrc Next, type startx, and the GNOME desktop environment will be started. If an older display manager, like XDM, is being used, this will not work. Instead, create an executable .xsession file with the same command in it. To do this, edit the file and replace the existing window manager command with /usr/local/bin/gnome-session: &prompt.user; echo "#!/bin/sh" > ~/.xsession &prompt.user; echo "/usr/local/bin/gnome-session" >> ~/.xsession &prompt.user; chmod +x ~/.xsession Yet another option is to configure the display manager to allow choosing the window manager at login time; the section on KDE details explains how to do this for kdm, the display manager of KDE. Anti-aliased Fonts with GNOME GNOME anti-aliased fonts X11 supports anti-aliasing via its RENDER extension. GTK+ 2.0 and greater (the toolkit used by GNOME) can make use of this functionality. Configuring anti-aliasing is described in . So, with up-to-date software, anti-aliasing is possible within the GNOME desktop. Just go to Applications Desktop Preferences Font, and select either Best shapes, Best contrast, or Subpixel smoothing (LCDs). For a GTK+ application that is not part of the GNOME desktop, set the environment variable GDK_USE_XFT to 1 before launching the program. KDE KDE About KDE KDE is an easy to use contemporary desktop environment. Some of the things that KDE brings to the user are: A beautiful contemporary desktop A desktop exhibiting complete network transparency An integrated help system allowing for convenient, consistent access to help on the use of the KDE desktop and its applications Consistent look and feel of all KDE applications Standardized menu and toolbars, keybindings, color-schemes, etc. Internationalization: KDE is available in more than 40 languages Centralized, consistent, dialog-driven desktop configuration A great number of useful KDE applications KDE comes with a web browser called Konqueror, which is a solid competitor to other existing web browsers on &unix; systems. More information on KDE can be found on the KDE website. For FreeBSD specific information and resources on KDE, consult the KDE on FreeBSD team's website. 安裝 KDE 如同 GNOME 或其他桌面管理軟體一樣, 也可以輕鬆透過 package 或 Ports Collection 來安裝: To install the KDE package from the network, simply type: &prompt.root; pkg_add -r kde &man.pkg.add.1; will automatically fetch the latest version of the application. To build KDE from source, use the ports tree: &prompt.root; cd /usr/ports/x11/kde3 &prompt.root; make install clean After KDE 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 .xinitrc file: &prompt.user; echo "exec startkde" > ~/.xinitrc Now, whenever the X Window System is invoked with startx, KDE will be the desktop. If a display manager such as XDM is being used, the configuration is slightly different. Edit the .xsession file instead. Instructions for kdm are described later in this chapter. More Details on KDE Now that KDE 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. The best reference for KDE is the on-line documentation. KDE comes with its own web browser, Konqueror, dozens of useful applications, and extensive documentation. The remainder of this section discusses the technical items that are difficult to learn by random exploration. The KDE Display Manager KDE display manager An administrator of a multi-user system may wish to have a graphical login screen to welcome users. XDM can be used, as described earlier. However, KDE includes an alternative, kdm, 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 (KDE, GNOME, or something else) to run after logging on. To enable kdm, the ttyv8 entry in /etc/ttys has to be adapted. The line should look as follows: ttyv8 "/usr/local/bin/kdm -nodaemon" xterm on secure XFce About XFce XFce is a desktop environment based on the GTK+ toolkit used by GNOME, 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 CDE, found on commercial &unix; systems. Some of XFce's features are: A simple, easy-to-handle desktop Fully configurable via mouse, with drag and drop, etc. Main panel similar to CDE, with menus, applets and applications launchers Integrated window manager, file manager, sound manager, GNOME compliance module, and more Themeable (since it uses GTK+) Fast, light and efficient: ideal for older/slower machines or machines with memory limitations More information on XFce can be found on the XFce website. Installing XFce A binary package for XFce exists (at the time of writing). To install, simply type: &prompt.root; pkg_add -r xfce4 Alternatively, to build from source, use the ports collection: &prompt.root; cd /usr/ports/x11-wm/xfce4 &prompt.root; make install clean Now, tell the X server to launch XFce the next time X is started. Simply type this: &prompt.user; echo "/usr/local/bin/startxfce4" > ~/.xinitrc The next time X is started, XFce will be the desktop. As before, if a display manager like XDM is being used, create an .xsession, as described in the section on GNOME, but with the /usr/local/bin/startxfce4 command; or, configure the display manager to allow choosing a desktop at login time, as explained in the section on kdm.