Total Pageviews

Search: This Blog, Linked From Here, The Web, My fav sites, My Blogroll

22 June 2010

FreeBSD --- X Window System

under editing...


Working with the X Window System

Window System(also known as X11 or X) is the UNIX world's equivalent of the Windows operating environment.
    UNIX systems owing to the usual niche of UNIX systems in server roles where a user-friendly application environment is seldom of any use. However, in recent years many people have sought to replace their Windows desktop systems with Linux or FreeBSD machines, and with that trend has come a plethora of software intended to make the venerable and downright arcane X11 windowing system more the seamless user experience that Windows offers. The X Window System comprises two parts:
  1. the X Server: The X Server runs as a daemon on your system and provides a graphical framework for applications to use.
  2. the window manager: The window manager determines how the X11 environment looks and feels.

Introduction to X11

The X11 system is a suite of programs developed at MIT and in the open-source community over the past two decades. Its current implementation, developed and endorsed by the X.org Foundation, is known as Xorg.
    As earlier discussed X11 has a client/server architectural model that lends itself well to clustered workstation configurations, but it can also work well on a single-user desktop computer as long as you understand the reasoning behind its seemingly curious design namely, why the separation between the X Server (the windowing system's heavy-lifting core) and the window manager exists.
    Like early versions of Microsoft Windows, X11 is a graphical "shell" that runs on top of the command-line operating system core; you first log in to the command-line environment and then you start up to go into the mouse-driven graphical mode where you can run applications such as web browsers and word processors. When you quit X11, you are returned to the command-line shell prompt.
    X11 itself is a very rudimentary structure. All X11 does is put the computer's interface in "graphics mode" (rather than the textual interface of the usual console screen), running programs in separate windows that can be painted at different positions on the screen. However, X11 running without a window manager shows only bare, unadorned, unlabeled, immovable, non-resizable program windows. X11 itself provides no menus, no utilities, and not even a mechanism for moving windows around. For that, you need a window manager and other extra tools, all of which run within X11 and handle the tasks you normally think of as being intrinsic to a windowing desktop environment.
    Some popular window managers include FVWM, Window Maker, AfterStep, and XFce; these window managers each have their own look and feel, and some are very carefully designed to mimic the appearance and behavior of Microsoft Windows, Sun's CDE, NeXTSTEP, or other popular user environments that have driven various operating systems over the years. More complex and polished user environments, better suited to heavy desktop use than plain window managers, include KDE and GNOME.
    You can install different window managers from the packages or ports, in /usr/ports/x11-wm. Assuming that you configured X11 during the installation or afterward, you should now be able to type startx at the command line to launch the X11 system.


The X Server
By itself, the X Server is not very useful it's just a mechanism for controlling basic window placement and application window painting, and it contains no window-management functions such as the ability to move a window by dragging it with a mouse. Figure shows an X Server running with no window manager. Several applications are running in the X11 session shown in Figure: an xterm (a command shell terminal window), a clock, a calculator, and the GIMP image-processing program used to take this screenshot. Notice that the windows have no title bars or borders. They are not resizable or movable, and they cannot be minimized or maximized. Obviously, this lack of flexibility makes for a pretty useless graphical user interface. This is where the window manager comes in.


Window Managers
The window manager controls how the graphical environment looks and works. In what is perhaps the most easily visible demonstration of the dynamics of the open-source software development community, rather than a single window management system being "blessed" for FreeBSD as would occur in a commercial operating system, dozens of different window managers are available for X11, as diverse in individual behaviors as the tastes of the people using them.
    Most window managers support "themes" as a central feature, allowing the user to swap out interface elements for new ones, so your user experience is almost infinitely customizable even within a single window manager. If you don't like the way X11 looks or feels, you can either customize your existing window manager or switch to a completely different one. Figure shows the same session as previous Figure, but this time it is running under the Window Maker window manager. In Figure 5.2 you see that each of the application windows now has a title bar with controls to maximize and close it. You can resize or move a window in any window manager interface. On the right side of the desktop is a menu from which you can launch applications by clicking an icon.
    Right-clicking the mouse on the desktop opens another menu from which you can select various options or launch applications. When you first configured X11 and launched your first graphical session, the window manager FreeBSD chose by default was TWM, a minimalist user environment with only the most rudimentary window decorations and control options. There's not much you can do in TWM you can launch windowed programs by typing their names at the command line in an xterm, you can move and resize windows, you can kill processes by clicking on them in the right way, and that's really about it.
    There are no icons and there's no file manager. There is no preference-setting utility. You can't even specify a background "wallpaper" image without the help of extra programs. For seasoned UNIX veterans who shun modern convenience, TWM is perfectly adequate, but if you plan on spending any significant amount of time using the X11 environment for desktop computing, you're going to find yourself wishing for the integrated features to which we've all become accustomed in modern desktop operating systems.
    Fortunately, to satisfy this need, FreeBSD makes available not one but two full-fledged user environment suites designed for this very purpose: KDE and GNOME.


KDE and GNOME
Are the two available user environments that best approximate the experience you'd have in Windows or Mac OS X. As is so often the case in the open-source world, KDE and GNOME, the two most widely used and enthusiastically developed user environments for UNIX, each have their impressive advantages and their inevitable weaknesses. Both also have sets of fierce advocates within the open-source UNIX community.
    Here in presenting the techniques necessary for setting up a fully immersive graphical user environment for FreeBSD, we must choose one package or the other for its demonstrations; an in-depth tour of both KDE and GNOME would be largely redundant, as both provide much the same benefits to the user, with features that are analogous if not identical (both KDE and GNOME have native web browsers and office suites, for example). KDE in execution tends to provide a user experience more akin to what you might be used to in Windows, with familiar metaphors and layout (such as a Start menu and Windows-like control buttons), and it has a more ambitious claim on the desktop computing world with advanced features such as text-to-speech synthesis and a password management utility and ...much other. This makes KDE perhaps a more likely choice for a casual or first-time user of FreeBSD than GNOME (shown in Figure), which offers a more unique style and set of metaphors, and is also considerably more lightweight than KDE, making it more appropriate for somewhat more seasoned UNIX veterans.
    For these reasons, and because the FreeBSD variant PC-BSD (which you might want to examine if you're interested in desktop computing rather than server applications) is built around it, this section will concentrate on KDE rather than GNOME.
    Fortunately, the setup process for KDE is similar to that of GNOME, and if you've set up one you should have little trouble setting up the other. Feel free to try both and decide for yourself which you prefer.
    Both KDE and GNOME are ambitious efforts to bring nothing less than a completely realized windowing environment to UNIX and Linux, with full sets of
Most X11 applications operate independently of the window manager you're using, and so a program such as the xv image viewer will work the same under FVWM as it does under Window Maker or TWM, with the exception of a different window border style. However, programs written for GNOME and KDE such as the Konqueror web browser or the Evolution email client are specifically designed to run only under their respective native windowing environments.
    Some of these specialized applications won't run properly or at all if you're not running the right windowing environment for example, text in a GNOME application might not show up because the expected font architecture isn't present if you run it under KDE.  
This downside, to purists, represents a lamentable departure from the traditional UNIX window-manager agnosticism that meant you could run any application under any desktop setup. 
However, the advanced technological underpinnings of KDE and GNOME apps mean that the freely available UNIX desktop environments are finally starting to reach the level of disciplined usability popularized by the Windows and Mac OS systems on every desktop.


Installing KDE
As extensive a program suite as KDE is, installing it is a relative breeze. The simplest method is to log in as root (or use su to assume root privileges), make sure you are connected to the Internet, and then type the following command:
# pkg_add -r kde3
This command connects to the FreeBSD FTP server and attempts to fetch all the required programs that make up the KDE 3.x package.
    This process might take an hour or more, so be patient; there are dozens of dependency packages that must be installed before KDE is complete.
Tip You can also install packages from within the Sysinstall program, as discussed during the installation procedure earlier. Type sysinstall, and then navigate to Configure, Packages, to browse the available packages visually. The kde3 package is in the x11 category.
If the pkg_add command fails for example, if it's unable to find the required packages on the server, or if you get an error during installation such as "Broken pipe" an alternative way to install KDE is to compile it yourself from the publicly available source code, using the ports tree (assuming you installed it during the installation procedure explained ealier). For now, though, all you need to do is type the following series of commands:
# cd /usr/ports/x11/kde3
# make
# make install
# make clean
After each of the make commands, FreeBSD fetches the latest source code for each component of KDE and begins compiling it into binary code.
    This process can take hours or even days, depending on the speed of your network connection and your computer hardware. Be patient and wait for each step to complete.
Note KDE and many of its dependency packages are "interactive" ports, meaning that at some point during the configuration of each one, you'll be presented with a text menu allowing you to select and deselect certain components that you may or may not need. Don't just start the compilation process and walk away FreeBSD might reach an interactive menu step and wait hours for you to come back to it!
Caution
  • A complete installation of KDE and all the components selected by default consumes over 2 gigabytes of disk space, and
  • compiling all the components from source consumes at least another gigabyte. Make sure you have at least several gigabytes of free space on your /usr partition before attempting to compile KDE from scratch.
  • Also, don't forget to type make clean at the end; this deletes all the source code and compiled objects that you don't need after KDE is installed.
  • You might choose to install the kde-lite package rather than the complete kde3 suite if you want the KDE environment but not all the space-consuming component applications.
Finally, when all these steps are done, KDE is installed on your computer; all that remains is for you to configure X11 to use the KDE environment instead of the default TWM. This can be accomplished most easily by setting up FreeBSD to use the KDM login manager instead of presenting the usual textual login prompt.


Enabling the KDM Login Manager
Open up the terminal configuration file, /etc/ttys, in a text editor such as ee:
# ee /etc/ttys
Use the arrow keys to move down to the line beginning with ttyv8; press Enter to create a blank line below it, and add a new line enabling KDM, the KDE Display Manager:
ttyv6   "/usr/libexec/getty Pc"         cons25 on secure
ttyv7   "/usr/libexec/getty Pc"         cons25 on secure
ttyv8   "/usr/X11R6/bin/xdm -nodaemon"  xterm off secure
ttyv9   "/usr/local/bin/kdm -nodaemon"  xterm on secure
# Serial terminals  
Then press Escape and press Enter, and then press Enter again to save your changes and exit. Finally, reboot your computer by typing: 

shutdown -r now
When your computer reboots, instead of the text login prompt, you should see a graphical login screen. Type your username in the Username box (or select your name from the user list at the left) and your password in the Password box, and then click OK or press Enter to log in to your first session with KDE.
Note1 KDM doesn't allow you to log in as the root user; you have to use your own regular user account. This is a security precaution, as is the fact that you cannot set up FreeBSD to boot automatically into a user account you have to log in by supplying a username and password.
Note2 Installing GNOME is very similar to installing KDE, with a couple of small exceptions. You can install GNOME from the packages (gnome2 in the x11 section) or the ports (/usr/ports/x11/gnome2); GNOME isn't an interactive port, and it has far fewer components than KDE, so it takes far less time to compile and install, and requires much less disk space.
To enable GDM (the login manager analogous to KDM), don't edit /etc/ttys; instead, edit /etc/rc.conf, the main system configuration file. Scroll to the bottom of the file and add the following line:
gdm_enable="YES"
Save the file. If you had earlier enabled KDM, edit /etc/ttys again to disable it by commenting out the ttyv9 line you added (place a hash mark, #, at the beginning of the line). Then reboot. The system will present you with the GDM login window when it comes back up.


KDE, The K Desktop Environment
When you successfully log in to KDE for the first time, you're greeted with a five-stage "wizard" that sets up KDE according to your preferences as a user. In these screens you specify
  1. your country and language; 
  2. then you choose the system behavior you want (whether KDE's windows should behave like they do in Windows, in Mac OS X, in classic UNIX, or in KDE's own style), 
  3. as well as the "theme" or visual look of the various controls used in the windowing system. 
KDE provides you with previews and descriptions of each of these behaviors and styles, so you can get a good idea of what you want before you choose it; don't worry you can always revisit these choices later using the KDE Control Center, available from the K menu. After you're done with the setup process, you'll see a splash screen and progress bar that indicate the stages of startup; this usually takes longer the first time you launch KDE than in subsequent sessions. Keep an eye out for error messages that might pop up in dialog boxes; they usually indicate problems with hardware, such as an inability to open the sound system, and most often they can be safely dismissed.After a few moments you'll find yourself at the KDE desktop, shown in Figure. Anyone familiar at all with Windows should immediately feel more at home in KDE than in just about any other desktop environment available for UNIX. KDE is laid out to recall the Windows desktop, with a
  • Start menu equivalent in the lower-left corner,
  • a taskbar along the bottom,
  • a configurable launch bar for commonly used applications,
  • Windows-like window controls, and a combined web browser/file manager called Konqueror. (Indeed, as you'll quickly discover, almost every component of KDE has a name beginning with K. Apparently, all the K indicates is the letter preceding the L of Linux.)
  • The icons on the desktop are laid out just like the ones in Windows XP, and even have rather the same design.
  • Launching an application puts a tiny bouncing version of the application's icon next to your mouse cursor, in what seems an homage both to the animated cursors of Windows and Mac OS X's bouncing Dock icons.
In fact, KDE even has a number of flashy features that Windows doesn't have. For example,
  • mousing over icons in the launch bar shows you an animated pop-up window that describes the icon and what it does;
  • mousing over an icon on the desktop or in a file browser window shows you a great deal of information about that file, including its last-modified date, ownership, permissions string, type-specific metadata, and even a preview for most file types.
Any of these features, by the way, can be turned off if they annoy you.
Note One benefit that KDE and GNOME both provide, and which is notably absent from both Windows and Mac OS X, is that upon login it will attempt to restore your session the windows that were open, the applications you were running, and the files that you'd had open in the state it was in when you last logged out.
It would be a mistake to say that KDE is self-explanatory if you've used Windows; inevitably, there are a number of potentially confusing differences between KDE and Windows, and although simply exploring the menus will teach you a great deal, the basics are important to understand.


Manipulating Files and Folders
KDE's equivalent of the Windows Explorer is a browser called Konqueror; like Microsoft Internet Explorer, it's both a web browser and a filesystem navigation system. If you single-click either the Home or System icons on your desktop, a Konqueror window opens to show you the contents of the item you selected.
    Home leads to your home folder (/home/), and System leads to the root of the filesystem (/). In the KDE paradigm, you can think of directories in the filesystem as "folders," as they're called in other desktop operating systems; each one has an appropriate folder icon that you can double-click to navigate deeper into the filesystem. Some folders have special icons, such as your Home folder (a house) and Desktop, which contains all the items that appear on your desktop. In this respect, KDE behaves very much like Mac OS X. Konqueror gives you three navigation modes, accessible using icons in the toolbar of the navigation window:
  • Icon view Files and folders are represented as icons, and can be arbitrarily placed in a window or sorted according to name, date, and other criteria.
  • Tree view Using an expandable "tree" hierarchy similar to the one in Windows, you can expand folders in-place to view their contents.
  • Photobook view Previewable files are shown in a vertical column at the right; clicking on one shows a preview of its contents in the middle of the window, which you can zoom to any magnification level and scroll back and forth using custom icons that appear in the toolbar when you're in this mode.
Tip Several other useful view modes are available in the View, View Mode menu, including MultiColumn view (similar to Mac OS X's Column view) and Info List View (which shows useful details such as the number of lines and characters in text files). Experiment with these view modes to determine what works best for you, and in what areas of the system.


Right-click on the desktop or the background of a folder window. A contextual menu, much like the one in Windows, gives you the capability to create new folders, text files, HTML documents, or documents associated with any of the KDE applications, links, or other items. On the left of the Konqueror window is a vertical series of shortcut icons; this list of icons, called the SideBar, includes
  • Bookmarks,
  • History,
  • Home Folder,
  • Root Folder, and
  • Services.
These icons take you directly to commonly traveled locations, or give you a means to retrace your browsing steps to find out where you've been. You can add folders into this bar to extend its usefulness as with the Finder Sidebar in Mac OS X:
  1. right-click in the SideBar, and
  2. then choose to add either a Folder, a Bookmarks pane, or a Web SideBar Module (a way to load a web page into the left-hand pane of the Konqueror file browser window).
  3. After the new item is created, right-click on it to customize its name, icon, and destination URL.

Browsing Files on Remote Volumes
KDE has an integrated remote volume browser that you can use to connect to shared resources on the network, whether they're WebDAV servers, FTP servers, Windows shares, or SSH connections.
  1. Open the K menu; under Internet,
  2. select KNetAttach (Network Folder Wizard). This wizard's first screen is shown in Figure 5.7.
  3. Choose the type of remote volume you want to connect to and
  4. click Next; fill out the required authentication information when prompted.
When you connect, you're given the opportunity to save the connection; if you do, you can then select it from the Recent Connection menu the next time you open the wizard. Using the Network Folder Wizard is probably the first time you'll encounter the KDE Wallet, which is a password archival system similar to the Keychain in Mac OS X. Whenever you connect to a password-protected resource (such as a remote folder or a secure website), KDE prompts you to keep the password you enter; this password gets stored in the Wallet. The first time you save a password, KDE requires you to enter a password to secure the Wallet itself. After you've done this, the Wallet is automatically opened when you log in, and it automatically supplies the passwords to the secure services that request them.
Caution Although the Wallet is secured with your password so that nobody else can access it when it's locked, it is automatically unlocked at the time you log in to KDE; this means that if the computer is in a shared environment, someone else can sit down at your unattended login session and gain access to your unlocked Wallet passwords. If you have any concerns about the trustworthiness of anyone who might have the opportunity to use the computer without your knowing, it's better to avoid the Wallet and instead simply memorize your passwords.

Switching Desktop Workspaces
In the middle of the taskbar at the bottom of the screen is a four-pane Desktop Switcher. A common feature to nearly all X11 window managers, a desktop (or workspace) switcher lets you work within a virtual desktop that's several times bigger than your actual screen space four times, in KDE's case. All the windows you open automatically appear in your primary workspace, which is synonymous with your screen; but if your screen starts getting too cluttered, don't start closing windows simply switch to another workspace. Just click on one of the other three desktop icons, and you'll switch to a new, clean desktop, free of windows. New windows you open while in a workspace other than your primary one stay in that workspace; the desktop icons show you rudimentary outlines of the windows on each one, reminding you of where your windows are even though they're off where you can't see them.Right-click in the title bar of any window and choose To Desktop to send that window to a different workspace.


Changing KDE's Look and Feel
  1. Open the K menu and choose Control Center. This opens the full-screen configuration browser shown in Figure 5.8.
  2. Under the Appearance & Themes heading, browse all the various sections that allow you to customize how KDE's interface elements appear: from the Background (where you can add any wallpaper image you choose) to the Theme Manager and Window Decorations sections, you'll be experimenting and tinkering for hours before you find just the look you're after.
After you're done customizing KDE's look and feel, it's worthwhile to look through some of the rest of the sections available in the Control Center. This application gives you access to all the aspects of system behavior that you'd find in the Control Panels of Windows, and even a bit more. You can configure your network settings and perform user management all from within KDE using these tools. You'll find that most of the common aspects of system administration are covered quite well in the KDE Control Center.


KDE Applications
KDE's major claim to fame, beyond just its familiar-feeling desktop metaphor, is the sheer number of component applications that are installed along with it. Just look through the submenus of the K menu to see how many apps are available in each of the categories: dozens, many of which are functionally equivalent to desktop applications costing hundreds of dollars in the commercial computing world, or at least aim to fulfill the same needs.
Note It should be noted that KDE's built-in applications also usually leave a lot to be desired, in terms of their end-user quality and useful feature sets. Fortunately, the open-source community has stepped up to the challenge and provided better alternatives in almost every category.
Here we will list only a few of the most important KDE apps that you'll find yourself using on a daily basis.
  • Konqueror More than just a file browser, it's also a fully capable web browser with all the cutting-edge features today's Internet users demand. Mac OS X users will be interested to note that Konqueror is based on the same HTML rendering engine KHTML that Apple adopted as the back-end for its Safari browser.
  • KOffice A feature-rich office suite comparable in capabilities to Microsoft Works (or, to a certain extent, Office). Although its documents aren't interoperable with the ones from Microsoft Word, Excel, PowerPoint, and so on, KOffice's applications among which are KWord, KSpread, KPresenter, Kivio, and the Photoshop-like Krita give users the power to produce professional documents that get the job done every bit as well as their commercial counterparts. (Demanding users will probably want a more ambitious office suite, such as OpenOffice.org,
  • KEdit An excellent, feature-rich text editor. Editing your configuration files might prove to be far easier in KEdit than in command-line editors where you're limited to keyboard navigation and input.
  • KMail A full-featured, HTML-based email application comparable to Outlook or Apple Mail, with all the modern spam-control and organizational features we expect in this modern age.
  • Quanta A web development suite complete with image-map editing tools and WYSIWYG layout.
  • KDevelop A full-fledged Integrated Development Environment (IDE) for C/C++. (Look into Eclipse for a still more highly polished IDE.)
This is only the tip of the iceberg; there's plenty more in each of KDE's application menus, including games and frivolities certainly the most important part of any desktop environment worth what you pay for it.


Logging Out of KDE
When you're done with your session, be sure to log out you can configure KDE to lock your screen saver with a password, protecting your personal information, but if the computer is shared with others, you want them to be able to log in when you're not around. Select Log Out from the K menu and choose to End Current Session (returning to the KDM login window), Turn Off Computer, or Restart Computer.


Advanced X11 Configuration

X11 is a very powerful server framework that can do much more than provide the basic desktop functionality that has been covered so far. Depending on your computing environment, you might find yourself needing to take advantage of the versatility and advanced features for which X11 was originally designed, such as in a clustered computing deployment where a central X11 server displays windows on remote client computers over the network. Similarly, if you have multiple UNIX users in a cluster or sharing a single computer, each one needs to be able to configure her X11 session to her own liking, using the X11 configuration files that each user can configure. This unit looks at these and other advanced features of X11, starting with techniques for optimizing the graphical performance of your video card and display hardware.


Configuring X11 with the xorgconfig Script
During the initial setup of FreeBSD you  used the full-screen xorgcfg program to set up a basic hardware configuration for your X11 server. Because of the variety of video cards and displays in the world today, and because X11 configuration is in many ways more art than science, it's entirely possible that xorgcfg alone was not able to get X11 set up properly for your computer. 
    Perhaps you couldn't get X11 to run at any higher resolution than 640x480, or perhaps you can't do any better than 8-bit color (256 colors). Perhaps you couldn't find an appropriate video driver in the xorgcfg database, and you had to guess. Or, perhaps, X11 won't start at all, and keeps cycling between several flickery or unstable graphics modes and never finds one that's stable. 
    There's another configuration script in Xorg that might help: xorgconfig. This tool is a linear script that asks you a series of questions and configures X11 based on the answers you provide; it's more difficult to use than xorgcfg, and much of it seems to duplicate the questions xorgcfg asks, but it does have a significantly better set of video chipsets and drivers from which to choose, and it might do a better job recommending an appropriate combination of refresh rates and color depths for your hardware.
Caution1 Improper use of this tool when configuring video settings could actually cause physical damage to your hardware. Although most modern monitors have built-in protection circuits and will shut themselves down if you try to drive them with a refresh rate higher than they support, some monitors will try to display the screen at the specified refresh rate, even if the monitor's hardware is not capable of handling it. The result could destroy your monitor.
Caution2 The xorgconfig program will overwrite your existing xorg.conf file. If you have a working xorg.conf file and you want to experiment with a new configuration, you should back up your existing file first. The file is located in /etc/X11/xorg.conf. Make a copy of this file to /etc/xorg.conf.bak (or some similar name) before continuing. This way, you can restore your previous configuration easily if your new configuration does not work by simply copying the backup file back to /etc/X11/xorg.conf.
You will need to be root to use this program. As the root user, type xorgconfig at the command prompt and press Enter. You will see a screen like the following:
This program will create a basic xorg.conf file, based on menu selections you
make.

The xorg.conf file usually resides in /usr/X11R6/etc/X11 or /etc/X11. A sample
xorg.conf file is supplied with Xorg; it is configured for a standard
VGA card and monitor with 640x480 resolution. This program will ask for a
pathname when it is ready to write the file.

You can either take the sample xorg.conf as a base and edit it for your
configuration, or let this program produce a base xorg.conf file for your
configuration and fine-tune it.
Before continuing with this program, make sure you know what video card
you have, and preferably also the chipset it uses and the amount of video
memory on your video card. SuperProbe may be able to help with this.

Press enter to continue, or ctrl-c to abort.
After you have read the information, simply press Enter to continue. The first thing you will be asked to configure is your mouse.
Caution Double-check your typing when entering values in xorgconfig. The program is not very forgiving of mistakes and typos. If you accidentally make a wrong entry and don't catch it before you have pressed Enter, there is no way to back up and fix it. You will have to press Ctrl+C to exit the program and then start over again completely

Configuring the Mouse
Caution PS/2 mice are notoriously finicky in many ways. A common problem is that the motherboard and operating system won't recognize a mouse that you plug in after the machine has been booted; but a more serious risk is that the motherboard might short out if you unplug the mouse while the machine is running.Always be sure to have all your non-USB devices plugged in before booting the computer, and leave them connected for the duration. 
The mouse-configuration screen of xorgconfig looks like this:
First specify a mouse protocol type. Choose one from the following list:

1. Auto
2. SysMouse
3. MouseSystems
4. PS/2
5. Microsoft
6. Busmouse
7. AceCad
8. GlidePoint
9. IntelliMouse
10. Logitech
11. MMHitTab
12. MMSeries
13. MouseMan
14. ThinkingMouse

The recommended protocol is Auto. If you have a very old mouse
or don't want OS support or auto detection, and you have a two-button
or three-button serial mouse, it is most likely of type Microsoft.

Enter a protocol number:
Simply enter the number representing the type of mouse you have and press Enter. In most circumstances, and with most standard PS/2 or USB mice, selecting 1 (Auto) is the best solution, especially if you were able to get your mouse working using the Auto setting in Sysinstall or xorgcfg. If you weren't, here are some guidelines for determining what type of mouse you have:
  • If your mouse has a nine-pin, D-shaped connector where it plugs into your computer, it is a serial mouse. Use either 3, 5, 10, or 13. Note that most serial mice will work with either 3 or 5 and that all newer Logitech mice will use either 5 or 13. Option 10 is only for extremely old Logitech mice. (Do yourself a favor and spend 15 bucks on a modern PS/2 mouse.).
  • If your mouse has a small round connector that plugs in next to the keyboard plug, it is a PS/2 mouse. Any PS/2 mouse should use option 4. Even if you have a Microsoft mouse, you should use 4 if it has a PS/2 connector. The Microsoft mice options listed are only for serial mice.
  • If you are installing FreeBSD on a laptop or notebook computer, the built-in pointing device will probably work with option 4 because it is most likely running on an internal PS/2 port. This includes touchpads and trackpoint-style pointing devices.
After you have entered the number for the type of mouse you have and pressed Enter, you will be asked the following:
If your mouse has only two buttons, it is recommended that you enable
Emulate3Buttons.

Please answer the following question with either 'y' or 'n'.
Do you want to enable Emulate3Buttons?
The first line of this message really should read "If your mouse has only two buttons, it is required (rather than recommended) that you enable Emulate3Buttons." Most window managers in X11 make use of all three buttons on the mouse, and some (such as Window Maker) depend on the middle button for accessing important menus. If you have a two-button mouse, you need to answer Y here; doing so will cause clicking both mouse buttons at the same time to emulate clicking the middle button on a three-button mouse. You will then be asked to give the name of the device the mouse is on:
Now give the full device name that the mouse is connected to, for
example /dev/tty00. Just pressing enter will use the default,
/dev/sysmouse.

Mouse device:
If you selected Auto for the mouse type, or if you were able to use your mouse properly when configuring it in Sysinstall or xorgcfg, just press Enter here to use the default system mouse driver. Otherwise, unless you have symlinked the actual device your mouse is on to /dev/sysmouse, you will need to enter the name of that device here. Table 7.1 shows guidelines on what you should enter, depending on what type of mouse you have Table 7.1. Device Names for Various Mouse Types Mouse TypeMouse
  • DevicePS/2 mouse (or laptop) /dev/psm0
  • Serial mouse on COM 1 /dev/cuad0
  • Serial mouse on COM 2 /dev/cuad1
  • Serial mouse on COM 3 /dev/cuad2
  • Serial mouse on COM 4 /dev/cuad3
  • Bus mouse /dev/mse0
Enter the corresponding mouse device name at the prompt and then press Enter.


Selecting the Keyboard
The next screen will ask you to select the type of keyboard you have:
Please select one of the following keyboard types that is the better
description of your keyboard. If nothing really matches,
choose "Generic 104-key PC"

1  Generic 101-key PC
2  Generic 102-key (Intl) PC
3  Generic 104-key PC
4  Generic 105-key (Intl) PC
5  Dell 101-key PC
6  Everex STEPnote
7  Keytronic FlexPro
8  Microsoft Natural
9  Northgate OmniKey 101
10  Winbook Model XP5
11  Japanese 106-key
12  PC-98xx Series
13  Brazilian ABNT2
14  Acer AirKey V
15  ACPI Standard
16  Azona RF2300 wireless Internet Keyboard

Enter a number to choose the keyboard.

Tip On some systems, you might not be able to see the top part of the keyboard list. If this is the case, you will need to press Enter several times until you have cycled through the entire list and returned to the beginning.
Notice that although only 16 keyboard types are immediately visible, there are actually more than 93 specific keyboard models listed in xorgconfig at the time of this writing, and the list of available keyboard layouts is too long to fit on one screen. Press Enter to see the next screenful of layouts. If you press Enter again at the end of the list, the display returns to the beginning of the list. If you have a U.S. keyboard, select 1 or 3 here and press Enter. You will then be asked to select the layout by language:
1  U.S. English
2  U.S. English w/ ISO9995-3
3  U.S. English w/ deadkeys
4  Albanian
5  Arabic
6  Armenian
7  Azerbaijani
8  Belarusian
9  Belgian
10  Bengali
11  Bosnian
12  Brazilian
13  Bulgarian
14  Burmese
15  Canadian
16  French Canadian
17  Croatian
18  Croatian (US)

Enter a number to choose the country.
Again, press Enter to scroll through the 90+ available region-specific layouts. U.S. users will likely want to choose 1. You're then asked the following:
Please enter a variant name for 'us' layout. Or just press enter
for default variant
There's generally no need to enter anything special here; just press Enter to proceed to the next question:
Please answer the following question with either 'y' or 'n'.
Do you want to select additional XKB options (group switcher,
group indicator, etc.)?
Enter N here unless you want to remap some keys. If you do want to remap some keys (or you just want to see what remapping options are available), press Y. This action presents a couple of menus in which you can do various things, such as make the Caps Lock key into a Ctrl key (useful for Emacs gurus) or swap the Caps Lock key with the Ctrl key. Enter the number of an option you want to perform and then press Enter. If you want to exit the menu without doing anything, simply press Enter without selecting a number first.


Configuring the Monitor
In this section of the configuration program, you configure various aspects of your monitor, including the horizontal and vertical refresh rates.
Caution The next few questions in the configuration are the parts that could potentially damage your monitor if you don't configure them correctly. Make sure you do not select frequency ranges higher than your monitor can support. Consult your monitor documentation for more information on the refresh rates that your monitor can support.
You first see this screen:
Now we want to set the specifications of the monitor. The two critical
parameters are the vertical refresh rate, which is the rate at which
the whole screen is refreshed, and most importantly the horizontal sync rate,
which is the rate at which scanlines are displayed.

The valid range for horizontal sync and vertical sync should be documented
in the manual of your monitor.

Press enter to continue, or ctrl-c to abort.
Press Enter at this message to continue. If you haven't done so already, take this opportunity to locate the manual for your monitor (or look up its specifications online) and determine its vertical and horizontal sync ranges. Even LCD monitors have sync frequencies. One excellent resource for finding the specifications of popular monitors from all manufacturers is located here .Tip If you can't find the sync information in your monitor's manual, and you can't find an entry in the MonitorWorld.com database, there's one more method you can try. If you've used this monitor in Windows, or if you can hook it up to a Windows machine, you can determine the refresh rate by looking at the Display Properties panel; select the Settings tab, click Advanced, and then click the Monitor tab to see what refresh rates Windows knows about for your monitor.When you've found what your monitor's horizontal sync range is, look it up in the list presented by the script:
You must indicate the horizontal sync range of your monitor. You can either
select one of the predefined ranges below that correspond to industry-
standard monitor types, or give a specific range.

It is VERY IMPORTANT that you do not specify a monitor type with a horizontal
sync range that is beyond the capabilities of your monitor. If in doubt,
choose a conservative setting.

hsync in kHz; monitor type with characteristic modes
1  31.5; Standard VGA, 640x480 @ 60 Hz
2  31.5 - 35.1; Super VGA, 800x600 @ 56 Hz
3  31.5, 35.5; 8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)
4  31.5, 35.15, 35.5; Super VGA, 1024x768 @ 87 Hz interlaced, 800x600 @ 56 Hz
5  31.5 - 37.9; Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz
6  31.5 - 48.5; Non-Interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz
7  31.5 - 57.0; High Frequency SVGA, 1024x768 @ 70 Hz
8  31.5 - 64.3; Monitor that can do 1280x1024 @ 60 Hz
9  31.5 - 79.0; Monitor that can do 1280x1024 @ 74 Hz
10  31.5 - 82.0; Monitor that can do 1280x1024 @ 76 Hz
11  Enter your own horizontal sync range

Enter your choice (1-11):
If you know the exact horizontal frequency range that your monitor can support, select 11 to enter the range manually. Otherwise, select a predefined range that does not exceed the range you know your monitor is capable of. In other words, make sure you select a narrower range than you know the monitor can handle, to ensure you won't be pushing it beyond its limits. After you have selected one of the predefined entries or entered your monitor's horizontal sync range, press Enter to move to the next screen, where you will be asked to set the vertical refresh rate:
You must indicate the vertical sync range of your monitor. You can either
select one of the predefined ranges below that correspond to industry-
standard monitor types, or give a specific range. For interlaced modes,
the number that counts is the high one (e.g. 87 Hz rather than 43 Hz).

1  50-70
2  50-90
3  50-100
4  40-150
5  Enter your own vertical sync range

Enter your choice:
Once again, it is very important that you do not select a refresh rate higher than your monitor can handle; otherwise, you may cause damage to your monitor. If you know the vertical refresh rate for your monitor, select 5 and then enter the refresh range for your monitor. Otherwise, you can select one of the first four predefined ranges, again making sure it doesn't exceed the range you know the monitor can handle from its experience with Windows. Press Enter after you have made your selection to continue on to the next screen:
You must now enter a few identification/description strings, namely an
identifier, a vendor name, and a model name. Just pressing enter will fill
in default names.

The strings are free-form, spaces are allowed.
Enter an identifier for your monitor definition:
This is the information that will show up in the xorg.conf file that the program will generate after you have finished entering all the values. All you're doing here is defining some labels to help you decipher the option blocks in the configuration file; the names don't have to conform to any particular standard. You can just press Enter here to let xorgconfig use default names such as My Monitor.


Configuring the Video Card 
Next, you will be given some information about configuring the video card. Press Y after you have read the informational screen; this gives you access to Xorg's complete card database. It will look like the following:
0  * Generic VESA compatible                         -
1  * Generic VGA compatible                          -
2  * Unsupported VGA compatible                      -
3  ** 3DLabs, TI (generic)               [glint]     -
4  ** 3Dfx (generic)                     [tdfx]      -
5  ** ATI (generic)                      [ati]       -
6  ** ATI Radeon (generic)               [radeon]    -
7  ** ATI Rage 128 based (generic)       [r128]      -
8  ** Alliance Pro Motion (generic)      [apm]       -
9  ** Ark Logic (generic)                [ark]       -
10  ** Chips and Technologies (generic)   [chips]     -
11  ** Cirrus Logic (generic)             [cirrus]    -
12  ** Cyrix MediaGX (generic)            [cyrix]     -
13  ** DEC TGA (generic)                  [tga]       -
14  ** Intel i740 (generic)               [i740]      -
15  ** Intel i810 (generic)               [i810]      -
16  ** Linux framebuffer (generic)        [fbdev]     -
17  ** Matrox Graphics (generic)          [mga]       -

Enter a number to choose the corresponding card definition.
Press enter for the next page, q to continue configuration.
Once again, there are far more cards listed in the database than can fit on one screen 566+ at the time of this writing. Press Enter to get to the next page. When you reach the end of the list, pressing Enter will start the list over at the first page. If you can't find your exact video card make and model number in this list, simply press Q to quit.
  • Don't select a model just because its name sounds familiar models that have similar names do not necessarily have similar hardware or capabilities.
  • However, the beginning of the list contains nearly 30 "generic" video drivers that you can select if your specific model isn't listed. For example, if you have an ATI Radeon 9200, and that particular ATI card model isn't in the list, simply scroll to the beginning of the list and choose option 6, which is a generic driver for all Radeon cards.
  • If all else fails, choose option 0 or 1 to select a generic VESA or VGA driver it won't have a lot of capabilities, but it will be almost sure to work.
  • If you do find the make and model of your video card in the list, enter its number and then press Enter.
You will then receive information about the video card you selected. Here's an example:
Your selected card definition:
Identifier: Matrox Millennium G400
Chipset:    mgag400
Driver:     mga

Do NOT probe clocks or use any Clocks line.
Press enter to continue, or ctrl-c to abort.
After you press Enter to continue, you are asked to give some more information about your video card, starting with the amount of RAM it contains: Now you must give information about your video card. This will be used for the "Device" section of your video card in xorg.conf. It is probably a good idea to use the same approximate amount as that detected by the server you intend to use. If you encounter problems that are due to the used server not supporting the amount memory you have, specify the maximum amount supported by the server.
How much video memory do you have on your video card:

1  256K
2  512K
3  1024K
4  2048K
5  4096K
6  Other
6  8192K
7  16384K
8  32768K
9  65536K
10  131072K
11  262144K
12  Other

Enter your choice:
The amount of video memory defines the resolution and color bit depth that your card will be able to support. Be sure you know the correct amount of video RAM available on your card; if you set this value too low, you won't be able to use some of the higher-resolution modes or take advantage of full color depth but if you set it too high, X11 might try to set the card to a mode that it can't support. This won't damage the card, but it will take extra time each time you start X11 as it tries the invalid mode and falls back to a less ambitious one. Most modern video cards have 32MB or more of video RAM; this is enough so that 24-bit color (16.7 million colors) is possible even at the highest resolutions. The xorgconfig script lets you directly specify as much as 262144KB, which corresponds to 256MB of video RAM. If you know you have a different amount from any of the listed options, choose 12 and specify the number manually. Remember to use kilobytes; multiply the number of megabytes by 1,024 to get the number of kilobytes to enter. Press Enter to continue on to the next screen:
You must now enter a few identification/description strings, namely an
identifier, a vendor name, and a model name. Just pressing enter will fill
in default names (possibly from a card definition).

Your card definition is Matrox Millennium G400.

The strings are free-form, spaces are allowed.
Enter an identifier for your video card definition:
If you selected a video card type from the card list, there will already be a suggested identification/description string listed here. I suggest that you accept the default that is given. If you couldn't find your card in the list, enter a brief description of your video card here and then press Enter. Depending on whether or not you selected a card definition from the database, you will be presented with a different set of questions. Read the appropriate upcoming section, depending on whether you did or did not select a card definition from the database.

Selecting a Card from the Database and Saving the Configuration File
  If you selected a card definition from the database list, you will be presented with a menu of currently configured video modes. The following shows an example of what this might look like:
For each depth, a list of modes (resolutions) is defined. The default
resolution that the server will start-up with will be the first listed
mode that can be supported by the monitor and card.

Currently it is set to:

"1280x1024" "1024x768" "800x600" "640x480" for 8-bit
"1280x1024" "1024x768" "800x600" "640x480" for 16-bit
"1280x1024" "1024x768" "800x600" "640x480" for 24-bit

Modes that cannot be supported due to monitor or clock constraints will
be automatically skipped by the server.

1  Change the modes for 8-bit (256 colors)
2  Change the modes for 16-bit (32K/64K colors)
3  Change the modes for 24-bit (24-bit color)
4  The modes are OK, continue.

Enter your choice:
You will probably want to make some changes here because, by default, X11 will start up in a resolution of 640x480, which is so small as to be virtually unusable. If you have a 17-inch monitor, you will probably want to go with at least 1024x768, and you may want to go even higher, depending on your needs. You'll be able to edit these settings at any time to adjust your display's resolution after you've used X11 enough to know how much screen real estate you'll need.Tip Of course, if you have an LCD monitor, you'll want to disable all video resolutions except for your monitor's native resolution. LCD monitors in interpolated resolutions usually look pretty bad. You will also want to decide what color depth to use. As a general rule, the higher the color depth, the better. If you have a small amount of video RAM, though, color depth and resolution may be a tradeoff. In general, you will not notice a difference in most applications between 24-bit and 16-bit color; however, the difference between 16-bit and 8-bit color is the difference between comfortable, seamless work and a constant barrage of palette shifts and dithered gradients. Although personal preference has to be the governing factor, here are my recommendations:
  • If the resolution you want to run does not allow more than 8-bit color (256 colors), it is probably better to reduce the resolution to a level that allows 16-bit color.
  • However, if getting more than 256 colors requires you to reduce the resolution to a value lower than 1024x768, you should really consider getting a newer video card.
  • If the resolution you want to run allows 16-bit color but does not allow 24-bit color, it is probably not worth reducing the resolution to allow 24-bit color. In most cases, unless you are doing something in which the number of colors is extremely important (such as graphics processing), you are not likely to notice the difference between 16-bit and 24-bit color.
After you have decided on the default color depth you want to use, you will want to make changes to the mode line for that color depth (unless you plan on running 640x480 resolution by default, in which case you do not have to make any changes). Enter the number for the series of modes you want to adjust and then press Enter. For example, if you plan to run 24-bit color by default, you would select 3 in the sample screen given previously. This will take you to a screen similar to the following.Select modes from the following list:
1  "640x400"
2  "640x480"
3  "800x600"
4  "1024x768"
5  "1280x1024"
6  "320x200"
7  "320x240"
8  "400x300"
9  "1152x864"
a  "1600x1200"
b  "1800x1400"
c  "512x384"
d  "1400x1050"

Please type the digits corresponding to the modes that you want to select.
For example, 432 selects "1024x768" "800x600" "640x480", with a
default mode of 1024x768.

Which modes?
Select the number corresponding to the default resolution that you want to use when X11 first starts up. For example, if you want X11 to start in 1024x768 resolution by default, select 4. If you want to be able to switch between different resolutions, you can enter multiple numbers here, in a combined string. The first number will be the default resolution, and the numbers listed after that will be cycled through in the order they are listed when you issue the command to change the screen resolution (generally Ctrl+Alt plus either the + or key on the numeric keypad). For example, if you want the default resolution to be 1024x768, the next resolution in the cycle to be 800x600, and the final resolution in the cycle to be 640x480, you would enter 432 here. Most people are not in the habit of changing the resolution on their screens at all once they have it initially set up. If you've never changed the screen resolution on your Windows or Macintosh system, chances are you won't in FreeBSD, either. Unless you anticipate having to flip back and forth between various resolutions for some reason, you can probably just set one resolution here.
Tip While you're still experimenting with your X11 settings here, it might be a good idea to specify at least one "safety" resolution, such as 640x480 (option 2). This allows X11 to fall back to that resolution if it can't put your system into the resolution you want, for instance if you specified the wrong sync frequencies for your monitor or the wrong amount of video RAM. You can always remove this resolution option later by editing xorg.conf manually.
When you have selected the resolution(s) that you want for this color depth, press Enter to continue. You will then be asked about virtual screens:
You can have a virtual screen (desktop), which is screen area that is larger
than the physical screen and which is panned by moving the mouse to the edge
of the screen. If you don't want virtual desktop at a certain resolution,
you cannot have modes listed that are larger. Each color depth can have a
differently-sized virtual screen

Please answer the following question with either 'y' or 'n'.
Do you want a virtual screen that is larger than the physical screen?
A virtual screen that is larger than the physical screen (a traditional X11 feature that isn't widely supported in the Windows/Mac world) means that your monitor, which may be limited in resolution, only displays a subset of X11's desktop area; you'll be able to pan across the virtual screen by moving your mouse to the edges of the displayed area.
Note For many users, virtual screens are more annoying than their utility is worth, as working with them can be very clumsy and inefficient; most users avoid the feature unless forced by a limited video card to use a very low resolution (such as 640x480). However, for users with limited visual acuity, the feature can be a godsend it lets you use a low, very readable screen resolution to make text large and legible, and lets you pan around the screen to see the entirety of the desktop, in a passable emulation of the Zoom feature in Mac OS X (itself designed for accessibility purposes).
If you do decide that you want a virtual screen, you will be asked for the resolution you want the screen to be. Select the desired resolution and press Enter. If you decide you do not want a virtual screen, you will be taken back to the mode line configuration screen shown earlier. The newly updated screen, with its currently configured mode lines, is shown here:
For each depth, a list of modes (resolutions) is defined. The default
resolution that the server will start-up with will be the first listed
mode that can be supported by the monitor and card.
Currently it is set to:

"1280x1024" "1024x768" "800x600" "640x480" for 8-bit
"1280x1024" "1024x768" "800x600" "640x480" for 16-bit
"1024x768" for 24-bit

Modes that cannot be supported due to monitor or clock constraints will
be automatically skipped by the server.

1  Change the modes for 8-bit (256 colors)
2  Change the modes for 16-bit (32K/64K colors)
3  Change the modes for 24-bit (24-bit color)
4  The modes are OK, continue.

Enter your choice:
Notice that the mode lines for 24-bit color have changed. It now has only 1024x768 resolution.Unless you plan to run multiple color depths, you can leave the other color depths alone. If you do plan to switch between color depths, simply select the number for the next color depth you want to configure and repeat the previous steps to configure the resolutions for that color. When you have finished configuring all the modes you want to configure, select 4 (The Modes Are OK, Continue) to move on to the next section.You will then be asked to specify the default color depth you want to use:
Please specify which color depth you want to use by default:

1  1 bit (monochrome)
2  4 bits (16 colors)
3  8 bits (256 colors)
4  16 bits (65536 colors)
5  24 bits (16 million colors)

Enter a number to choose the default depth.
Simply select the number for the color depth you decided on earlier and then press Enter. After you have selected the desired color depth, you will be asked whether you want to save the changes:
I am going to write the xorg.conf file now. Make sure you don't accidentally
overwrite a previously configured one.

Shall I write it to /etc/X11/xorg.conf?
Select Y to write a new xorg.conf file. If you already have an xorg.conf file, it will be overwritten with the new file. After you have selected Y and pressed Enter, xorgconfig will respond with the following:
File has been written. Take a look at it before running 'startx'. Note that
the xorg.conf file must be in one of the directories searched by the server
(e.g. /etc/X11) in order to be used. Within the server press
ctrl, alt and '+' simultaneously to cycle video resolutions. Pressing ctrl,
alt and backspace simultaneously immediately exits the server (use if
the monitor doesn't sync for a particular mode).

For further configuration, refer to the xorg.conf(5) manual page.
At this point you're done with the script and will be returned to the command prompt. Your xorg.conf file has been written and its operation is ready to test. Skip ahead to the section "Testing the X11 Setup."

Configuring a Card That Is Not in the Database and Saving the Configuration File
If you did not select one of the cards from the card list database (if you pressed Q instead of choosing a listed card driver), the first question you will be asked is how much video memory your card has:
Now you must give information about your video card. This will be used for
the "Device" section of your video card in xorg.conf.

It is probably a good idea to use the same approximate amount as that detected
by the server you intend to use. If you encounter problems that are due to the
used server not supporting the amount memory you have, specify the maximum
amount supported by the server.

How much video memory do you have on your video card:
1  256K
2  512K
3  1024K
4  2048K
5  4096K
6  8192K
7  16384K
8  32768K
9  65536K
10  131072K
11  262144K
12  Other

Enter your choice:
If you know how much video RAM your card has, choose it from the list or enter it manually (in kilobytes) by choosing option 12. Otherwise, you can proceed by specifying an unrealistically high number, such as option 9 (64MB); this number doesn't directly affect the card's configuration, but tells xorgconfig what display resolutions and color depths it should offer you. You can always edit the X11 configuration file, after you're done with this script, to use video modes that don't tax your video card's capabilities or call your bluff.
You must now enter a few identification/description strings, namely an
identifier, a vendor name, and a model name. Just pressing enter will fill
in default names (possibly from a card definition).

The strings are free-form, spaces are allowed.
Enter an identifier for your video card definition: blah
You're now asked to enter a card identifier. Because you didn't select a card model, this identifier is important for future diagnostics; enter a label that describes your card as best you can. The next screen asks you what default color depth you want to use:
Please specify which color depth you want to use by default:

1  1 bit (monochrome)
2  4 bits (16 colors)
3  8 bits (256 colors)
4  16 bits (65536 colors)
5  24 bits (16 million colors)


Enter a number to choose the default depth.
Select the number corresponding to the default color depth you want and press Enter. You will then be asked whether you want to save the changes:
I am going to write the xorg.conf file now. Make sure you don't accidentally
overwrite a previously configured one.

Shall I write it to /etc/X11/xorg.conf?
Select Y here to write the configuration file. This will overwrite any existing configuration file you may have. After you have written the changes, xorg.conf will respond with the following message and then exit:
File has been written. Take a look at it before running 'startx'. Note that
the xorg.conf file must be in one of the directories searched by the server
(e.g. /etc/X11) in order to be used. Within the server press
ctrl, alt and '+' simultaneously to cycle video resolutions. Pressing ctrl,
alt and backspace simultaneously immediately exits the server (use if
the monitor doesn't sync for a particular mode).

For further configuration, refer to the xorg.conf(5) manual page.
By default, X11 will start in 640x480 resolution. You will probably want to change this to a higher resolution. You will need to edit the xorg.conf configuration file manually in order to do so. The xorg.conf file is covered in the next section.


Understanding the xorg.conf File
Like most other components of FreeBSD, the X11 configuration is controlled by a configuration file that is in plain text. The primary X11 configuration file is located in /etc/X11 and is called xorg.conf. This is the file that is created or modified by xorgcfg (the menu-based interface for X11 configuration you used back in an earlier section) and also by xorgconfig (the text-based configuration script that was covered in previous sections). These configuration tools have made X11 configuration much easier than it used to be when the files had to be created and edited entirely by hand. However, there are still some situations in which you might need to make changes to the configuration file by hand. For example, if your video card was not listed in the card database, you might need to make manual changes to this file to fine-tune it to your card's capabilities. Another situation in which you may need to make changes by hand is if you want to make changes to aspects of X11 that xorgconfig doesn't address, such as the acceleration or speed settings for the mouse. If you simply want to make one or two minor changes to X11, it may be desirable to edit the file by hand rather than go through a complete configuration with xorgconfig. To make changes to the xorg.conf file, first make a backup copy of the file so that it will be easy to undo your changes if they cause problems. For example, you might want to copy /etc/X11/xorg.conf to /etc/X11/xorg.conf.bak. After you have a backup copy, open the file /etc/X11/xorg.conf in your favorite text editor.

xorg.conf Syntax 
The xorg.conf file is divided into several sections. Each section relates to a specific device or configuration issue, and begins with the keyword Section followed by the section name in quotes. Each section ends with the keyword EndSection. The body of the section is indented for easy readability. Comments, or lines that are ignored by X11, begin with a pound sign (#). The following is an example of a section in the xorg.conf file:
Section "Module"

# This loads the DBE extension module.

Load        "dbe"   # Double buffer extension

# This loads the miscellaneous extensions module, and disables
# initialization of the XFree86-DGA extension within that module.
SubSection  "extmod"
Option    "omit xfree86-dga"   # don't initialize the DGA extension
EndSubSection

# This loads the font modules
Load        "type1"
#    Load        "speedo"
Load        "freetype"
#    Load        "xtt"

# This loads the GLX module
#    Load       "glx"
# This loads the DRI module
#    Load       "dri"

EndSection
The comments before this section are not shown, but in the xorg.conf file, they explain what the section is for. In this case the Module section loads dynamic modules when the server starts to support various components of the system. For example, the part of this example that begins with # This loads the font modules loads dynamic modules to support various types of fonts. In this case, the first Load line loads a module that supports Adobe Type 1 fonts. The second active Load line loads the freetype module, which is a freely available module that allows X11 to use commercial TrueType fonts. In addition to main sections, there are also subsections that can be embedded within the sections. These begin with the keyword SubSection followed by the name of the subsection in quotes, and end with the keyword EndSubSection. Like the main sections, they are also indented for readability purposes.


Section "Module"
The Module section is where modules can be dynamically loaded to support X11 components such as various font types. Dynamically loaded modules are not a part of the X binary; instead, these modules are loaded as needed when X11 starts. The advantage of dynamically loaded modules is that they are loaded only if they are needed. Modules that are not needed are not loaded and therefore do not waste memory and system resources. For example, if you don't have any TrueType fonts on your system, there is little point in having TrueType font support in X11, and you can comment out the Load "freetype" line. Modules that are to be loaded begin with the keyword Load followed by the name of the module in quotes. For example, the following line loads the module that supports TrueType fonts: Load "freetype"


Section "Files" 
This section is similar to the X11 PATH environment variable. The Files section tells X11 where in the system it can expect to find various required files.The only portion of this section you may ever want to modify is that which tells X11 where to look for fonts. Each one of the font directories begins with the keyword FontPath, followed by a directory enclosed in quotation marks. For example, the following line is where the Adobe Type 1 fonts are located: FontPath "/usr/X11R6/lib/X11/fonts/Type1/" This is the directory in which you would install new Adobe Type 1 fonts that you may download or purchase.
If you do add new font directories, the name of the directory is not really important. For example, there is nothing that says that Adobe Type 1 fonts have to be stored in a directory called Type1. This convention is just followed to make it easier for you to guess what types of fonts are in a directory.

Section "ServerFlags"
The ServerFlags section of the file contains some global options that control the behavior of X11. Some of the available options are present in the configuration file generated by xorgconfig and include comments about what they do. All the options are commented out by default. All the options in this section begin with the keyword Option, followed by the option in quotes. For example, the following line will disable the Ctrl+Alt+Backspace sequence that kills the X Server immediately: Option "DontZap" The following subsections discuss some (though not all) of the options available in ServerFlags you're most likely to use.
  • Option "NoTrapSignals" If this option is uncommented (enabled), X11 will not exit cleanly when there is a problem. Instead, it will write a core dump file. This can cause problems with the console not working correctly after X11 has terminated incorrectly. You should probably leave this line commented out unless you are experiencing consistent X Server crashes. In that case, uncommenting this option creates a core dump file that is invaluable for troubleshooting purposes. Even if you are not a programmer and cannot make heads or tails of the dump file, it will be an important piece of evidence if you want to file a bug report with the Xorg project developers.
  • Option "DontZap" If this option is uncommented, you will not be able to kill the X Server by using the Ctrl+Alt+Backspace key combination. You should definitely not uncomment this line until you have tested your X11 configuration and are sure it is working correctly. This option is helpful if you're setting up a kiosk or a public computer where it's important that users not have the ability to exit from the running application or escape from the X11 session.
  • Option "DontZoom" If this option is uncommented, it will disable video mode switching using Ctrl+Alt++ and Ctrl+Alt+ (on the numeric keypad). By default, these key combinations will allow you to cycle between different video modes if you have configured multiple video resolutions. About the only reason for uncommenting this would be if you have programs that require these key combinations for some other use. In this case, uncommenting this line will prevent the X Server from intercepting the combination and causing the video modes to switch in the middle of your work.
  • Option "DisableVidModeExtension" If this option is uncommented, it will prevent the xvidtune program from making any changes to the video system. If this is a multiuser system, it may be a good idea to uncomment this line to prevent users from being able to use xvidtune because the improper use of xvidtune can damage your monitor. Note that if the line is uncommented, xvidtune can still be loaded. But you will not be able to make any changes to the video system with it. Most of the other options in this section that are present in the configuration file generated by xorgconfig should probably be left alone.

Other Options Not Present by Default for Section "ServerFlags" 
Several other options may be of interest that are not present in the default configuration file generated by xorgconfig. We are not going to discuss all of them here, but many of the more useful ones are listed. If you want to add any of these following options, simply add the line in bold text to the ServerFlags section in xorg.conf:
  • Option "AllowMouseOpenFail" By default, if the X Server cannot communicate with the mouse or other pointing device, the server will not start and will exit with an error. Adding this line will allow the server to start, even if the mouse or other pointing device cannot be accessed.Unless you are trying to use X11 without a mouse or other pointing device, there is probably no reason to change this option.
  • Option "BlankTime" "n" This option will cause the screen to go blank after the number of minutes represented by n. If this option is not present, the default is 10 minutes.
  • Option "StandbyTime "n" This option will cause the monitor to go into standby mode after the number of minutes represented by n. If this option is not present, the default is 20 minutes.This option is not supported by all video drivers, and it only works with monitors that support DPMS power-saving features. The Monitor section of xorg.conf (discussed later) must explicitly specify that the monitor can support DPMS for this feature to apply.
  • Option "SuspendTime" "n" This option will cause the monitor to go into suspend mode after the number of minutes represented by n. If this option is not present, the default is 30 minutes. This option is not supported by all video drivers, and it only works with monitors that support DPMS power-saving features. The Monitor section of xorg.conf (discussed later) must explicitly specify that the monitor can support DPMS for this feature to apply.
  • Option "OffTime" "n" This option will turn the monitor off after the number of minutes represented by n. If this option is not present, the default is 40 minutes. This option is not supported by all video drivers, and it only works with monitors that support DPMS power-saving features. The Monitor section of xorg.conf (discussed later) must explicitly specify that the monitor can support DPMS for this feature to apply.
  • Option "NoPM" This option will disable some events that relate to power management. By default, power management is enabled on systems that can support it. You should need to add this option only if you are experiencing strange problems that seem to be related to power-management events.
A few other options can be included in this section, but they are less commonly used. If you are interested in some of the other options available, see the man page for xorg.conf. 


Section "InputDevice" 
This section is where the input devices are configured. There can be multiple InputDevice sections in the configuration file. Usually there will be at least two: one for the keyboard and one for the mouse or other pointing device. InputDevice sections have several keywords associated with them.
  • The first is the Identifier keyword. It is followed by a name that identifies this device. X11 doesn't really care what you call the device, but it is best to use a descriptive name that defines it well enough for your own purposes.
  • The second is the Driver keyword. It is followed by the name of the driver for this device, in quotes.The most common drivers are "keyboard" and "mouse", but there are a few others such as "microtouch" for a touch screen.
  • The final part of the InputDevice section consists of options for the device.The following sections look at the two most common InputDevice sections the keyboard and the mouse and discuss some of the option lines available for configuring them.
Configuring the Keyboard Options Here is an example of the first part of the InputDevice section for the keyboard:
Section "InputDevice"  

Identifier  "Keyboard1"
Driver      "kbd"
You can choose from a number of available options for controlling keyboard behavior. Here are some of the most commonly used of these options:
  • Option "Protocol" If this option is omitted or commented out, the default value of "Standard" will be used. There is probably no reason to change this.
  • Option "AutoRepeat" "x y" This option controls the repeat rate of the keys on the keyboard. The number represented by x is the delay in milliseconds before the key starts repeating. The number represented by y is the number of times per second that the key will repeat. The default is 500 milliseconds before the key starts to repeat, and 30 times per second that it will repeat.
  • Option "XkbRules" "xorg" This option determines the way various aspects of the keyboard are interpreted. In most cases, you should leave this set to "xorg" unless you chose an atypical keyboard type in the xorgconfig script.
  • Option "XkbModel" "pc104" If you have a 105-key Windows keyboard, this will be "pc105". If you have a 101-key keyboard that does not have the Windows keys, it will be "pc101". These values will also work for laptops. Even though laptops usually have fewer keys, they generally have ways of emulating the additional keys.
  • Option "XkbLayout" "us" This will usually be set to "us". If you are using the Japanese PC-98 platform, you will want to change it to "nec/jp". Again, running xorgconfig is probably the best way to set this option for your needs.
  • Option "XkbOptions" "ctrl:swapcaps" If this line is uncommented, it will cause the Caps Lock key to become a Ctrl key and the left Ctrl key to become a Caps Lock key. You may want to uncomment this line if you are an Emacs guru (Emacs relies heavily on the Ctrl key) or if you are used to a UNIX keyboard layout in which the Ctrl key is placed in the position where the Caps Lock key is found on PC keyboards.
Configuring Mouse Options Here is an example of the first part of the InputDevice section for the mouse:
Section "InputDevice"

# Identifier and driver

Identifier  "Mouse1"
Driver      "mouse"
Option "Protocol"    "Auto"
Option "Device"      "/dev/sysmouse"
The following subsections describe some of the most commonly used options.

Option "Protocol" "protocol" In this option, protocol represents the type of mouse that your system has. This option is required, and the X Server will not work if it is not present. Many users will be able to get away with specifying Auto here to have the X Server automatically attempt to determine the protocol the mouse uses. This usually causes no problems these days; but if it does, several other options are available. A few of the more useful protocol types follow:
  1. The Logitech protocol is used only by very old Logitech serial mice. If you have a newer Logitech serial mouse, use the Microsoft or MouseMan protocols.
  2. Use the PS/2 protocol for any PS/2 mouse, no matter who the manufacturer is. You have a PS/2 mouse if the mouse connector is a small round one. If you have a laptop or notebook system, the built-in pointing device (such as a touchpad or trackpoint) will probably work with the PS/2 protocol. I suggest that you try using Auto first and then change it only if your mouse is not detected or is not working properly.
Option "Device" "devicename" This option specifies what device the mouse is driven by. The option is required, and the X Server will not work if this option is missing.Table 7.1 (earlier) lists some of the common device names where your mouse may be located. Note that devicename in this option should be replaced with the mouse device.

Option "Buttons" "n" In most cases, the number of buttons on the mouse will be automatically detected; if they are not, this option can be used to tell the X Server how many buttons are on the mouse.Here, n represents the number of buttons the mouse has. The most common values are 2 and 3, although numbers up to 5 are supported. If you happen to have a mouse with five buttons on it, go for it.

Option "Emulate3Buttons" This very important line allows a two-button mouse to emulate a three-button mouse. If you have a two-button mouse, you will want to uncomment this line because X11 makes extensive use of all three mouse buttons.If you do uncomment this line, the middle mouse button is emulated by pressing the left and right mouse buttons at the same time (a "chord").

Option "Emulate3Timeout" "n" If the Emulate3Buttons option is enabled, this option will control the number of milliseconds that can elapse between clicking the left and right mouse buttons before X11 will no longer interpret the action to be a middle click. In other words, both the left and right mouse buttons must be pushed within this time frame in order for the action to be interpreted as a middle click. Here, n is the number of milliseconds that can elapse. If this line is not present and the Emulate3Buttons option is enabled, the default Emulate3Timeout value will be 50 milliseconds.


Section "Monitor"
This is where you configure the horizontal and vertical refresh rates for your monitor. It consists of the Identifier keyword followed by a name in quotes to identify this monitor. The name you choose is not very important. Two other keywords are required to be present in this section: HorizSync and VertRefresh. You learn more about them in the following sections. A few other options can be used with the Monitor section, but they are not as common. For full details on all the available options, see the man page for xorg.conf.

 HorizSync HorizSync is the horizontal sync rate in kilohertz that the monitor supports. It can be specified in several ways:
  1.  As a range This is normally the method used to configure multisync monitors (and virtually all CRT monitors are multisync these days). For example, HorizSync 44-76 would be used for a monitor that can support horizontal refresh rates ranging from 44 to 76 kilohertz.
  2.  As a single value If you have a fixed frequency monitor that supports only one frequency, it is simply listed after HorizSync (for example, HorizSync 35.2).
  3.  As a list of frequencies If your monitor supports several fixed frequencies, you can supply a list of the fixed frequencies that it supports, separated by commas (for example "HorizSync 31.5, 35.2").
  4.  As multiple ranges of frequencies If your monitor supports more than one range of frequencies but has a gap in the middle that it does not support, you can list multiple ranges (for example, "HorizSync 15-25, 30-50").
 VertRefresh The VertRefresh keyword lists the vertical refresh rate your monitor can support. It can take its value in any of the same formats that the HorizSync keyword can use.
 Caution Supplying values for HorizSync and VertRefresh that are outside the range of what your monitor can support can damage or destroy your monitor. Be extremely careful that you do not supply values outside the supported range. See your monitor's documentation or check the manufacturer's website (or here) for technical specifications to find the values your monitor can support.

Section "Device"
This section is where you configure your graphics adapter (video card). Like most other sections, it begins with the keyword Identifier, followed by a name in quotes to identify the device. The Driver keyword is also required, followed by the name of the driver for your card in quotes. For example, if you have an NVIDIA TNT2, the line would look like this: Driver "nv" If you have a supported video card, it is much easier to go through xorgconfig (explained earlier) to set up the graphics device than to do it manually in the xorg.conf file. However, if for whatever reason you need to or want to do it manually, a full list of the supported cards, along with the driver that should be used to support each card, is available here in "Hardware Compatibility Lists." The other keyword that is most commonly used here is the VideoRam keyword to specify how much video RAM the video card has. For example, if your video card has 16MB of RAM, the line would look like this: VideoRam 16384 As you learned earlier, the amount of video RAM is specified in kilobytes; in binary math, a kilobyte is actually 1,024 bytes. Be sure to multiply your card's megabyte value by 1,024 to get the value you have to specify in the configuration file. Some more options are available for graphics devices, but most of them will not be needed for most video cards. See the man page for xorg.conf for full details on all the available options. Also, you will probably want to have a look at the web page located here to see whether there are any notes regarding your particular type of video card and any specific options you need to supply for it.
Tip If you cannot find a driver for your video card, all may not be lost. You might be able to get the card working with the VESA driver. VESA is a generic Super VGA specification that a lot of cards support to some extent. If you have to use this driver, the accelerated features of your card will not be fully supported, and nor will all the resolutions and color depths that your video card can handle. But it's better than nothing, and it may allow you to use a card for which there is no driver currently available for X11. If you end up using this alternative, check the supported card database often because support for new cards is being added on a regular basis.

Section "Screen"  
The Screen section is where a monitor is combined with a graphics card to make a "display" construct that will work with the X Server. It starts with the Identifier keyword that contains a name enclosed in quotes, identifying this particular combination of monitor and video card. There can be multiple Screen sections present in the xorg.conf file, but there must be at least one. The first one encountered will be the one that is used unless specified otherwise in the ServerLayout section. After you have specified an identifier for the Screen section, you also must specify the "devicename", "monitorname", and DefaultDepth "n" keywords. Other available options are rarely used; see the man page for xorg.conf for details on these options.
  • Device "devicename" This is the name of the graphics device (video card) that should be used for this screen configuration. Here, devicename is whatever string appears in the Identifier section of the graphics device that you set up earlier in the file.
  • Monitor "monitorname" This is the name of the monitor that should be used for this screen configuration. Here, monitorname is whatever string appears in the Identifier section of the monitor that you set up earlier in the file.
  • DefaultDepth "n" This is the default color depth that should be used for this screen configuration. Valid values for n are 8, 16, and 24, assuming your video card supports all three color depths.
SubSection "Display"
After you have configured the Screen section, you will need to configure the Display subsection(s) for the screen, to specify the resolutions and cycle order for each available color depth. There must be at least one Display subsection for the default color depth, or the X Server will not start. However, there can be more than one Display subsection, one for each color depth.The first line in the subsection will be the keyword Depth followed by the color depth that this subsection is for. Here is an example of what the first two lines of this subsection might look like: Subsection "Display" Depth 24 The third line that is required here is a mode line. It is simply the keyword Modes followed by a list of the resolutions you want to have supported. The first resolution listed will be the default. The resolutions listed after that will be cycled through when the Ctrl+Alt++ and Ctrl+Alt+ key combinations (using the keypad) are used. Note that this may not work on some systems.Here is a sample mode line: Modes "1024x768" "800x600" "640x480" In this example, the default resolution will be 1024x768 for this color depth. Pressing Ctrl+Alt++ or Ctrl+Alt+ will cause X11 to switch to 800x600 and 640x480, in order. X11 allows you to have a virtual screen that is larger than the resolution you have configured. For example, you can have your screen resolution set to 800x600 and have a virtual screen size of 1024x768. This was discussed in a previous section of this chapter when we talked about configuring X11 with the xorgconfig program.If you decide that you want to use a virtual screen, you can use the "Virtual resolution" option to configure the resolution the virtual screen should be. For example, "Virtual 1024x768" will set the virtual screen size to 1024x768. If the actual screen resolution is lower than this, only part of the screen will be visible. To see the portions of the screen that are not visible, you will need to drag the mouse pointer off the edge of the screen. This will scroll the screen left, right, up, or down, depending on which edge of the screen you are interacting with. Some other options are available here but are not commonly used. For a list of all the options available in the Display subsection, see the man page for xorg.conf.


Section "ServerLayout"
The ServerLayout section is optional. If it does not exist, the first screen listed and the first keyboard and mouse input devices listed will be used. If the ServerLayout section does exist, it is used to select from among multiple screen entries and keyboard and mouse entries to be used during your X session.The Identifier keyword is required, and it is followed by a string in quotes that gives this server layout a name. Here are some of the other items commonly used in the ServerLayout section:
  • Screen "screenname" This is the screen configuration that should be used for this device. Here, screenname is the name listed in the Identifier keyword for the Screen section that is to be used for this server layout.
  • InputDevice "keyboardname" "CoreKeyboard" This determines which keyboard entry should be used for this server layout. Here, keyboardname is the name listed in the Identifier keyword for the Keyboard section you want to use. The CoreKeyboard option that follows sets this keyboard to the default keyboard.
  • InputDevice "mousename" "CorePointer" This is like the Keyboard entry, except that it determines the mouse entry that should be used for this server layout. Once again, the CorePointer option that follows sets this mouse to the default mouse.
Option lines can also be included in the ServerLayout section. If they are included and they conflict with options listed in other sections, the options listed here will override the other options. Other options are available for all aspects of the xorg.conf file, but most of them are rarely used. Once again, see the man page for xorg.conf for full details of all the available configuration options.


 Testing the X11 Setup
After you have finished with xorgconfig and/or hand-edited the xorg.conf file and saved your changes, you are ready to test the X Server.
  1. Type startx at the command line to start the X11 system. If all goes well, your screen will go blank for a moment, and you should soon see a checkered background with a small x in the middle, as you saw in Figure 2.13 earlier. The x is the mouse pointer.
  2. After a few more seconds, the window manager should come up, the mouse pointer should turn into a more familiar white or black arrow, and you should be able to move the mouse around on the screen.
  3. If you can't move the mouse or if X11 seems to start but then quits with an error message, double-check your xorg.conf file to make sure you have everything configured properly. Caution If you start X11 and your screen appears to be garbled, or you hear a high-pitched whine coming from your monitor, immediately turn your monitor off and press Ctrl+Alt+Backspace to kill the X Server. Either one of these symptoms indicates that you are probably driving the refresh rate of your monitor higher than it can tolerate, and the flyback transformer in your monitor is getting ready to fry. After you have killed the X Server, reconfigure the sync rates and resolutions for your monitor in xorg.conf or with the xorgconfig script.
  4. If you type startx and your monitor goes blank and then seems to turn off or go into a suspend mode (the power light changes color, starts blinking, or you can hear the static on the monitor discharging), it probably means you have driven your monitor past the specs it can tolerate. Press Ctrl+Alt+Backspace to kill the X Server. This should restore your screen and give you the command prompt back. Then, reconfigure your refresh rates and resolutions in xorg.conf or with the xorgconfig script, specifying less ambitious resolution settings, before trying again.After you have a working X11 setup, you may want to make some customizations to the way it works. The next section covers your personal .xinitrc file in your home directory.

Your Personal .xinitrc File
Individual users don't have to worry about the configuration of the X Server; it's handled at the root level of the system, running as a daemon when queried by clients (window managers). The window managers are user processes, and each user has the ability to choose a window manager to suit his or her taste, regardless of the hardware-limited resolutions you've defined in the xorg.conf file. Each user controls how his X11 session looks and acts using a shell script file in his home directory called .xinitrc. One of the most common setup attributes controlled by this file is
  • which window manager is to be invoked to handle the client end of X11's client-server architecture during your X session.
  • You also can use this file to control which applications start automatically every time you run X11,
  • the background color of the screen, and
  • the display of a background image.
Each of these operations involves making changes to your personal .xinitrc file.


 Changing the Window Managers
Many window managers are available in the x11-wm category of the FreeBSD ports tree or packages. One popular window manager only briefly mentioned previously is Blackbox. Blackbox is an ideal minimal window manager for users who don't want the window manager to get in the way. It is also ideal for systems that are low on resources. Blackbox is a common window manager used on servers. However, the instructions in this section apply to any window manager you install.
Note KDE and GNOME both behave somewhat differently from regular window managers. If you want to invoke KDE when you run startx, instead of using the KDM login manager, use this line in .xinitrc:
exec startkde
For GNOME, use the following:
/usr/X11R6/bin/gnome-session
After you have installed a new window manager from the ports or packages, you must edit your personal .xinitrc file to use it. Open the .xinitrc file located in your home directory in your favorite text editor. If the file does not already exist, it will be created. In this case, all you want to do is tell X11 what window manager to use, so you only need to add one line to the file. For Blackbox, here's the line to add:
exec blackbox
Each window manager has its own executable name; look in the pkg-plist file in any window manager's port directory to find out what the executable is called, and use it in place of blackbox here. After you have added the appropriate exec command to the .xinitrc file, save the file and exit the editor; the next time you start X11, you will be placed in the new window manager. Configuration of window managers other than Window Maker is beyond our scope here. See the web page for your chosen window manager for more information; the website is usually listed in the port's pkg-descr file. (In the case of Blackbox, see here).
Note Many other window managers are available for use with X11, and can be installed from the FreeBSD ports collection under the x11-wm directory.For more information, including screen shots of the more popular window managers, see here.

 Starting Applications Automatically
Remember that .xinitrc is a shell script, executed at launch time when you run startx. That means you can include anything in it that you want executed whenever you start X11, including certain X applications such as xterm windows or commonly used productivity apps. Any applications that you want to start automatically should be added before the window manager is invoked, and should end with an ampersand character (&). (Note that there should be a space before the ampersand). This way, they start in the background and detach from the shell executing the script, allowing it to proceed to the next command. If you don't end each command with an ampersand, it will start in the foreground, blocking the script from ever reaching and launching the window manager. Here is an example of an .xinitrc file that starts an X terminal window and an X clock along with the Blackbox window manager:
xterm &
xclock &
exec blackbox
Many of the programs you can execute within an X session are instrumented with options that let you define exactly where and how they appear. For example, to specify an xterm window of 80 columns by 25 lines, positioned at 100 pixels from the left edge and 50 from the top, use this line: xterm -geometry 80x25+100+50 & Many other X11 programs can be invoked with similar arguments; see their man pages, usually under the -geometry option, for details.

 Setting a Background Color or Background Image
Many window managers and desktop environments such as Window Maker and GNOME have the built-in capability to set their own background colors or background images. However, some of the simpler window managers, such as FVWM and wm2, do not. You can set the background color or background image by calling external programs from the .xinitrc file, as explained in the following subsections.

  Setting the Background Color
 By default, X11 has a rather ugly checkered background that seems as though it's designed to be as hard on the eyes as possible. The program xsetroot allows you to set the background color to a solid color or to a tiled bitmap from an image. There is a text file that lists all the available named colors located in /usr/X11R6/lib/X11/rgb.txt. Here is an example of how the background color can be set to a solid color: xsetroot -solid ForestGreen Try typing this command from an xterm window to set the background to forest green.If you want this change to be permanent, you can add this command to your .xinitrc file before the window manager starts. For example, the following line will set the background color to forest green and then start the twm window manager:
xsetroot -solid ForestGreen &
exec twm
The color you use must be a valid color that is listed in the rgb.txt file, and if the color has a space in it, the name of the color must be enclosed in quotation marks. In addition to setting the background color or pattern of the desktop, xsetroot can also change the appearance of the mouse pointer. See the man page for xsetroot for details on how to configure bitmapped backgrounds and also how to change the mouse pointer using a custom bitmap. You can create your own bitmaps to use as the background and as the mouse pointers with the bitmap program, which is installed as part of X11. Figure 7.2 (right)shows the bitmap program. X11 does not come with any program that allows you to set a full-size "wallpaper" image in your desktop background. However, there is an image-viewing program called xv that is traditionally used for this task. xv is available in the ports collection under the graphics directory. Figure 7.3(left) shows xv running in interactive mode. xv supports most common image formats, including GIF, JPEG, BMP, and PNG, and you can use a picture in any one of these formats as a background image. The following command is an example of how xv can be used to load an image as a background image for X11:
xv -root -quit /hone/btman/images/myimage.jpg
This command tells xv to load the image myimage.jpg onto the root window (which is the background of the window manager). It also tells xv that it should quit as soon as it has loaded the image. (This gets around the need to append an ampersand to the command line if you include it in your startup script). In order to have this image loaded as the background each time you start X11, you could do something like the following in your .xinitrc file:
xv -root -quit /home/foobar/images/myimage.jpg
exec twm
Some of the other options you may want to use with xv when using it to load background images include -max, which will cause the image to be resized and take up the entire available screen size, and -maxspect, which will cause the image to be resized to take up the entire available screen size within the limits of maintaining the proper aspect ratio of the image.


Working with Fonts
Sooner or later, you will probably want to install additional fonts in X11 for your applications (such as GIMP). Although X11 supports several types of fonts, the most commonly installed are Adobe Type 1 and TrueType. Both are extremely popular because they are supported by Windows and Macintosh, as well as newer versions of Xorg. Thousands of Type 1 and TrueType fonts are available free for download from various places on the Internet. Also, commercial fonts are available for purchase in both formats, and X11 can use them regardless of whether they're packaged as "Windows" or "Mac" fonts. Because these are the most commonly used font types, the following sections describe their use and configuration.

 Checking the xorg.conf File for Font Support
The first thing you will need to do is make sure the xorg.conf file contains the proper modules to support the fonts you want to use. The xorg.conf file was covered in detail under the section "Understanding the xorg.conf File," earlier. You need to check the file /etc/X11/xorg.conf for the appropriate Load line under the Module section.This line is necessary to support Adobe Type 1 fonts: Load "type1" This line is necessary to support TrueType fonts: Load "freetype" The preceding lines need to be located under the following heading in xorg.conf: Section "Modules" You also need to make sure an appropriate font directory exists in the Files section to hold the new fonts. Look for the lines in xorg.conf that begin with FontPath. If you are installing a TrueType font, I suggest that you add the following line after the last FontPath statement in the file to hold all your TrueType fonts: FontPath "/usr/X11R6/lib/X11/fonts/TrueType/" After you add this line, save the file and then exit the editor.

 Creating the Directories and Installing the Fonts
 Now, you must create the directory, if it doesn't already exist. As root, issue the following command:
# mkdir /usr/X11R6/lib/X11/fonts/TrueType
This command creates the directory for the TrueType fonts.
Note You may notice that X11 is one subsystem that doesn't obey the traditional FreeBSD separation between the /usr/local subtree and the rest of the system. When you install additional fonts for use in X11, it's a good idea to create a location for them within the design of the FreeBSD filesystem, such as /usr/local/X11/fonts (with appropriate subdirectories for different font types), and then use additional FontPath lines in xorg.conf to tell X11 to look for your fonts there. That way, if you have to perform a backup or transfer your system's data to a new installation, your downloaded and purchased fonts will be safely stored along with everything else in /usr/local
When you have a directory for the fonts, copy the font files for the fonts you want to add into the appropriate directory. Type 1 fonts should be copied into /usr/X11R6/lib/X11/fonts/Type1, and TrueType fonts should be copied into /usr/X11R6/lib/X11/fonts/TrueType. The fonts only need read access, so you may want to change the permissions on the fonts so that they only have read access for everyone. You can do this with the following command:
# chmod 444 fontname
Here, fontname is, of course, the name of the font file you just installed. (Make sure you are currently in the right font directory). Next, you must run a couple of programs to set up the fonts correctly.
  • To set up TrueType fonts, you need the program ttmkfdir. It is available in the FreeBSD ports collection under the directory x11-fonts.
  • To set up Adobe Type 1 fonts, you need the program type1inst, also available in the FreeBSD ports collection under the x11-fonts directory (its port name is p5-type1inst, as it's a Perl package).
After you have copied the fonts to the appropriate directory, make sure you are in that directory and type one of the following commands at the command prompt.For TrueType fonts:
# ttmkfdir > fonts.scale
For Adobe Type 1 fonts:
# type1inst > fonts.scale
You now must run just one more command: the mkfontdir command recognizes the new fonts and adds them to the font configuration file. To set up scalable fonts, such as Type 1 and TrueType, you need to run the command with the -e option. Once again, make sure you are in the directory to which you copied the fonts and then issue the following command from the prompt:
# mkfontdir -e /usr/X11R6/lib/font/encodings
Next, restart X11 (if you are currently in it), and your new fonts should be available for use.
Note Whenever you add new fonts to the system, you must repeat ttmkfdir or type1inst, followed by the mkfontdir procedure.


 Using Remote X11 Clients
In the separable client-server architecture of X11, applications can be run on a central host and have their output and input redirected to a remote host, as is common in clustered computing environments or college campuses.
  • Using a remote client can be useful, for example, if there's a collaborative graphical application hosted on a high-powered server and you need to be able to control it from a workstation that may not be powerful enough to run it.
  • Another example of where this setup is useful is if the central application is very expensive and only licensed for one installation, but you need to be able to access it from any X11-capable client computer on campus;
X11 makes this system possible and transparent, not to mention cost-effective. In a way, this remote use is similar to simply using SSH to log in to a remote system and then run a text-based application. The application is actually running on the server; the output and input are just being sent to your system. X11 extends this concept to graphical applications as well as text-based applications. However, this capability is disabled by default and needs to be enabled before it can be used.
The confusing aspect of using remote clients is that the terms client and server are reversed when dealing with X11. In networking terminology, you think of a "client" as being a host that runs applications located on another system known as a "server." In X11, however, the server is running on the local system, and the client is located on a remote system. Basically, a client in X11 is any program that runs under the X11 system. To make things even more confusing, your X Server may be running a client located on a remote system, which is actually a server. For example, you might load a graphical database administration client located on a remote system onto your X Server. In this case, your client is located on a remote system, but the remote system is a database server. In order for any of this to work, the system on which you want to display the output of and control the input of the remote X11 application must be running an X Server.
However, the X Server does not have to be on the same type of system. The X Server can be running on another FreeBSD system, a Linux system, a Solaris system, or a Mac OS X system. The system doesn't even have to be a UNIX-based system. There are X Servers available for Windows that can display remote X applications running on FreeBSD. Right now, the large majority of them are commercial, but an X server package for Windows, Cygwin/X, is available, and so you should be able to take part freely in the distributed X experience even from a Windows machine. By default, your X Server will not allow remote applications to be displayed on your screen. There are a few common ways to allow this. The most common, but also the least secure, is by using xhost.


 Using xhost to Allow Remote Applications to Be Displayed
 xhost will allow remote applications running on a different system to be displayed locally on your system and take their input from your system. To see the current xhost configuration settings, type xhost with no arguments. Here is what the default xhost configuration will return:
# xhost
access control enabled, only authorized clients can connect
In this case, only applications being run on remote systems that appear in this system's authorization list will be allowed to be displayed on this system. Also, the list is currently empty, meaning that no clients are currently authorized to send their display to this system.If you want to be able to run remote applications on the host named lion, you need to add it to the authorization list. To do this, you use the following command:
# xhost +lion
lion being added to access control list
If you type xhost now without any arguments, the system responds with this:
# xhost
access control enabled, only authorized clients can connect
INET:lion.example.com
The remote host lion which, in the context of our earlier examples, might be a mainframe in a lab across campus running a super-expensive CAD or rendering applicationcan now display its X11 applications on your local system.The problem with this setup is that anyone who has an account on lion can send the display of its applications to your system, whether you want them to or not. This can be a major security problem in an environment with untrusted users. It's therefore not a good idea to use xhost in these environments; other methods are available that are more secure. These are discussed briefly later. Also, if you do use xhost, it is probably a good idea to authorize a host only just before you need it and then remove the authorization as soon as you are done working with the remote application. To revoke authorization from a host, you can use a command like the following:
# xhost -lion
lion being removed from access control list
The remote host lion can no longer display applications on this system. There is also a way to completely disable access control in xhost so that any clients can connect to the system at will. This is probably never a good idea because it is a serious security hazard. But if for some reason you want to do it, you can use the following command:
# xhost +
access control disabled, clients can connect from any host
To enable access control again, type
# xhost -
access control enabled, only authorized clients can connect
Caution Because of the security hazards involved with xhost, at a minimum you will want to have a firewall configured that blocks unauthorized users from outside the internal network from accessing the ports that xhost uses. xhost uses ports 6000 through 6063.
After you have configured the system to allow a remote application to display on it, you need to connect to the remote system and start the application. You can do this through Telnet, SSH, or rlogin (though be aware that Telnet and rlogin, being unencrypted communication methods, expose you to terrible security risks).
Tip If you are connecting to the remote system by using an X Server running on Windows, make sure you use the Telnet or SSH application included with your X Server software. Because the Windows Telnet application knows nothing about the X Server, it does not work correctly for the procedures described in the following sections. Also, as mentioned earlier, it's unencrypted and thus a grave security risk.

 Starting a Remote Application
To start an application on the remote host and have it display its output on the local system, you need to set the DISPLAY environment variable on the remote host to your local system. You can do this from the SSH session. In your connection window to the remote host, you can usually use something like the following to start a remote application and display it on your system (this example assumes that your local host is named simba):
# DISPLAY=simba:0; export DISPLAY
# xcalc &
This code is for a Bourne-style shell (that is, sh, korn, or bash). If you are using a C shell (csh or tcsh), replace the first line with the following:
# setenv DISPLAY simba:0
This code should start an xcalc on the remote host and display the output on your screen. The DISPLAY environment variable has the following syntax: DISPLAY=hostname:display#:screen# Here, display# is almost always set to 0, and you can usually eliminate screen# unless you are on a system that has multiple screens attached to it.
Tip Make sure you enter the information in the SSH window that is connected to the remote host. Entering the information on a local xterm window will not have the desired effect

 Other Client Access Controls
There are other ways to control which hosts can display applications on the local host. Some of these ways are more secure than using the xhost method described here. The other methods and their configuration are beyond our scope here. However, you might want to read the man page for Xsecurity to get you started. (Note that this name is case-sensitive when you try to access the man page.)


 Using the XDM Graphical Login Manager
 You've already seen how to use the graphical login managers built into the KDE and GNOME systems, KDM and GDM. These login systems provide a nice, seamless, graphical experience from startup to shutdown of your system, making sure users logging in on the local console can enter their KDE or GNOME sessions securely, without having access to the command-line shell. KDM and GDM can even be configured to launch users' X11 sessions under other user environments or window managers than KDE or GNOME. However, these methods might not produce the desired effect, if you want to ensure that all users of the system have the ability to completely control their X11 sessions, including their .xinitrc startup scripts, using window managers other than KDE or GNOME. XDM is the traditional graphical login manager for the X11 system, independent of any window manager or environment the user might choose. When it is run at system startup, it displays a graphical login prompt rather than the text-based login prompt at the console. The graphical login prompt is similar to a Windows 2000/XP login screen, and operates the same as KDM or GDM, but with a lot less flash and polish. It's also customizable with your own bitmaps if you want to get creative. If you want to use XDM in your X11 sessions, you should edit a file called .xsession in your home directory. This file is the XDM equivalent of the .xinitrc file that the console login uses. It should contain the command to start your desired window manager, as well as the commands to start any applications you want to run automatically at boot time. All the commands in the .xsession file should end with an ampersand (&) so they start in the background. The following is what a sample .xsession file could look like:
#exec wmaker
xterm &
This would start the Window Maker window manager and also start an xterm automatically after login.Note that unlike the .xinitrc file, the .xsession file needs to be executable; otherwise, it will not work. Other than that, the two files can be the same; you can save yourself some aggravation by simply making .xsession a symbolic link to .xinitrc, and then setting .xinitrc executable:
# ln -s .xinitrc .xsession
# chmod +x .xinitrc
You can run XDM manually by typing xdm at the command line instead of startx; but this isn't an especially good idea for two reasons:
  1. It doesn't really get you any additional convenience; you end up having to log in twice, once at the command line and again in XDM.
  2. If you're worried about console security, it doesn't help at all, as anyone can come up to the machine and press Ctrl+Alt+Backspace to kill XDM and then they'll be dropped to your logged-in root shell.
A better solution is to have XDM launch automatically at boot time, the same way that KDM or GDM does. Setting up XDM is very similar to setting up KDM: you need to edit the /etc/ttys file, and enable the already present ttyv8 line to invoke XDM automatically.
ttyv5   "/usr/libexec/getty Pc"         cons25  on  secure

ttyv6   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv7   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv8   "/usr/X11R6/bin/xdm -nodaemon"  xterm   on  secure
ttyv9   "/usr/local/bin/kdm -nodaemon"  xterm   off secure
# Serial terminals
Be sure that the fifth field is set to on. At the same time, if you'd previously configured KDM, disable it by setting its fifth field to off. Save the file and reboot the system. XDM should start automatically on the next system boot. If killed, it will just launch itself again, preventing users from being dropped to your root shell. XDM is very configurable, and details of its configuration are beyond our scope here. See the man page for information on the various configuration files available to configure XDM.
 

Setting Up the X Window System (X11)

The X Window System, also known as X11 (or simply X), is the ubiquitous windowing system for UNIX and Linux. Originally developed at MIT in the early 1980s, X reached its eleventh major revision in 1987, and was subsequently released to the public as an open-source project, and was developed through several more releases by the X Consortium. Development stalled for several years during the 1990s, at which time X11's rather arcane client-server architecture and lack of modern features did not daunt the geeks experimenting with FreeBSD and Linux they, after all, loved a challenge. However, since 2004, a new organization called the X.org Foundation (founded by the X Consortium and sponsored by a number of deep-pocketed corporations such as IBM, Sun, and Hewlett-Packard) has been pursuing a modernization of X11 with renewed vigor. You will learn more about the day-to-day operation of X11 for now, the goal is to get X11 installed on your computer so that you can run graphical applications. This is not by any means an easy task. Rest assured, though, that it used to be a whole lot worse. If you did not install the X Window System during the procedure described here, or if you don't want to use X11 at all, you can skip this section. If you change your mind, you can always install X11 later install the xorg package, or build the port /usr/ports/x11/xorg in the ports collection.

 
Auto-Detecting Your Video Hardware
The core of X11 is what's called the X Server, a daemon that "serves" windows to a client program that draws the windows on the screen. This arrangement may seem confusing if you're coming from the Windows world. Just remember that X11 was originally developed for cluster-based computing, where many relatively low-powered computers in a lab or in dorm rooms around a campus would run lightweight window manager programs to request application windows from a central mainframe server. All the computing power, and all the applications, were centrally stored; in this context, it makes sense for the windowing system's heavy lifting to be done where all the power is, letting the client computers remain low-powered and inexpensive. Today, powerful desktop computers are cheap and plentiful, and cluster computing is all but obsolete; in this environment, the X Server and the windowing client (known as a "desktop" or "window manager") both run on the same computer. This greatly simplifies many aspects of installing and managing a graphical user environment on a UNIX system like FreeBSD. However, it doesn't change the fact that you have to set up the X Server first and independently before you can configure the client end of the equation, the desktop.
Note Double-check to make sure you know the specifications of your monitor (vertical and horizontal sync rates) and the make and model of your video card, including how much video RAM is installed. X11 does its best to auto-detect this information, but chances are that you'll have to supply it yourself at some point during this procedure, even if it's auto-detected at first.
The first step is to run a utility that auto-detects your video hardware. Make sure you're logged in as root (if not, type logout and log back in as the root user); then type:
# Xorg -configure
This program probes your video card to detect its chipset and capabilities, and writes out a skeleton configuration file for the X Server. This file, saved into the /root directory, is named xorg.conf.new. Examine this file to see what it found out. Use the following command to page through the file:
# less xorg.conf.new

Use the up and down arrows to move up and down line by line(or the spacebar and W key to page up and down).

Skip through until you find the section labeled Section "Device". In the lines in this section, you should see information describing your video card:
Section "Device"
### Available Driver options are:-
### Values: : integer, : float, : "True"/"False",
### : "String", : " Hz/kHz/MHz"
### [arg]: arg optional
#Option     "SWcursor"                  # []
#Option     "HWcursor"                  # []
#Option     "NoAccel"                   # []
#Option     "ShowCache"                 # []
#Option     "ShadowFB"                  # []
#Option     "UseFBDev"                  # []
#Option     "Rotate"                    # []
Identifier  "Card0"
Driver      "nv"
VendorName  "NVidia / SGS Thomson (Joint Venture)"
BoardName   "Riva128"
BusID       "PCI:1:0:0"
EndSection
Make sure this information agrees with what you know about your video card, and note the values for the Driver, VendorName, and BoardName fields. They'll be important as you further configure the X Server.
Note If you're working with an already-installed version of FreeBSD 5.2.1 or earlier, the X11 implementation included with FreeBSD is XFree86, the older and more stagnant version, not Xorg. Configuring XFree86 is much the same as configuring Xorg; only a few commands are different. To run the hardware auto-detection script, type the following:
# XFree86 -configure
The file written by this program is XF86Config.new, rather than xorg.conf.new.

 Testing the X Server
 Next, you need to test the operation of this auto-detected configuration. Type the following command:
# Xorg -config xorg.conf.new
  • The X Server launches using your newly created, bare-bones configuration file. Because the file contains no high-resolution screen modes or information about your monitor's capabilities, the best you can hope to see is a black-and-gray grid pattern that looks like diagonal burlap, and an X-shaped cursor in the middle of the screen. If you see this, you're in luck; X11 will work with your video card in at least its simplest display mode.
  • Try moving the mouse. If the cursor moves, count yourself doubly lucky you've got a working mouse driver. If not, make sure you enabled the mouse driver during the initial installation procedure; if you didn't, you'll need to enable it now. Type: sysinstall  . To reenter the Sysinstall program, and then navigate to Configure and then Mouse. Follow the instructions in the "Configuring the Mouse" $. There are no controls in this test mode of X11; to end the test, press Ctrl+Alt+Backspace. This will return you to the command prompt.
Caution Always remember the Ctrl+Alt+Backspace keystroke this is your way out of X11 if something goes haywire. If the display doesn't appear correctly (for example, if you see a lot of wavy lines instead of a stable grid and cursor), press Ctrl+Alt+Backspace immediately to kill X11. If you let X11 run for too long in a video mode that your CRT doesn't support, you could permanently damage the monitor.
 

Configuring Xorg with xorgcfg

The next step is to tell X11 how it should treat your display. You're about to embark on a research project; whereas a lot of the configuration of X11 has come a long way in recent years, the process of determining a monitor's capabilities is still a matter of trial and error. Your monitor is capable of several resolutions (pixel counts); this is determined by the vertical and horizontal sync rates that it can support. Your monitor's manual should tell you the appropriate sync ranges. If not, you should be able to look it up online by simply doing a Google search on your monitor's make and model, adding the keywords refresh rate or vertical sync if necessary. A monitor with a given vertical and horizontal sync range can only support certain resolutions; if the sync rate is too low for a chosen resolution, the display might be too flickery to use, or the monitor might not be able to use that resolution at all. Now that you know the driver name to supply for your video card, you need to use it as the basis for a more full-fledged X11 configuration file than the one you created earlier. There is a graphical or text-mode configuration tool called xorgcfg that you can use for this purpose. Running this program in graphical mode under X11 might be tempting, but it's better to use it in text mode for now, just to be safe the text-mode version works a lot better. Type the following command:
# xorgcfg -textmode
Note If you're using an older FreeBSD installation with XFree86, use the command:
# xf86cfg -textmode
After all the driver modules are loaded, you enter a full-screen textual utility similar to Sysinstall. Read the introduction screen and select OK. You enter a Main Menu screen with several options. Go through each of the menu options in order. In each area, you set up a profile for your mouse, keyboard, display, and so on, giving each a name (such as Mouse0, Keyboard0, and so on).
  1. First select Configure Mouse and specify an identifier such as the given Mouse0. The default port setting, Auto, should be appropriate for a standard PS/2 mouse. Otherwise, select the appropriate port. Enable three-button emulation if desired, and then specify the mouse driver (/dev/sysmouse is generally appropriate).
  2. Next, select Configure Keyboard to set up your keyboard in the same manner. Select the appropriate keyboard layout for your region, for example U.S. English.
  3. Next you need to configure your monitor (select Configure Monitor). From the list of horizontal sync rates presented, scroll until you find one that matches your monitor's capabilities as listed in its manual or online specs. If you've used this monitor in Windows, you can use that to help you determine the monitor's capabilities if you know you've been able to run in 1280x1024 mode, for example, you can choose an option such as 31.5 79.0; Monitor That Can Do 1280x1024 @ 74 Hz. Just make sure you don't choose too high a frequency if X11 tries to put the monitor into a mode with a sync rate higher than it can support, you could end up blowing out your monitor. Try selecting the lowest sync rate for the resolution you know the monitor can handle, and then you can work up from there later. Better safe than sorry! Similarly, choose a vertical sync rate corresponding to your monitor's specs. Choose a range narrower than what your monitor can support, if possible; if your monitor is listed as being capable of 45120 Hz, choose 50100, or enter the sync rate manually to match the monitor's specs exactly.
  4. Next you need to select Configure Card to specify your video card's driver. This is where it's important to know what the auto-detection script thought your card is; because xorgcfg doesn't read in that file's contents automatically, you have to specify the card settings again manually. View the card database when it's offered, and scroll through the list until you find an entry matching your card's make and model. Note FreeBSD's support for modern video cards is difficult to pin down. There is support for almost all recent NVidia cards explicitly available in the driver database, but ATi cards are woefully unrepresented. If you can't find your card in the list, choose Unlisted Card and proceed to the next screen where you can pick the driver manually.If you have an ATI Radeon card or any of several other modern 3D-accelerated cards, you might need to add support for them in the kernel before X11 will recognize them. A final fallback option is to choose the vesa driver and choose a resolution of 800x600; this setting will support almost any video card made in the last few years, though it won't have any 3D acceleration.Choose a driver appropriate to your card. This can be tricky, as the drivers are cryptically named. Remember that nv is the NVidia driver, ati drives ATi cards, and mga is the Matrox driver. You should be able to select the same driver name that was originally configured in the auto-detection phase, earlier; it's what was listed in the Driver field in xorg.conf.new.
  5. Next, choose Configure Screen. This is where you define the color depth of your display modes. This bit depth is limited by the amount of video RAM on your card. Most video cards produced in the last few years have plenty of video RAM, and displaying 24-bit color even at the highest resolutions is no problem; but if you have an older video card, this can be an important consideration. Again, if you used this computer for Windows previously, you should know what bit depths and at what resolutions you were able to run the video card; if not, choose a modest bit depth, for example 8 Bit, 256 Colors. (You can fine-tune this setting later, either by rerunning this configuration program, or by editing the config file manually, if you want to get 16-bit or 24-bit color.)
  6. In the next screen, use the arrow keys and the spacebar to place an X next to each of the resolutions you want to be able to use. X11 tries the highest resolution first, and then goes down the list to lower and lower resolutions if it can't put the display into that mode. Try selecting 1152x864, 1024x768, 800x600, and 640x480 tried-and-true resolutions that any monitor should be able to handle.
  7. Select Configure Layout to define a layout. This isn't really important if you only have one combination of monitor, keyboard, mouse, and video card, but it doesn't hurt.
  8. Finally, select Write xorg.conf and Quit. This lets you choose to install the new global config file into /etc/X11/xorg.conf so that it applies to all users who start X11 from the local console.

Fine-Tuning the xorg.conf File
After you're done with xorgcfg, you'll want to edit the file it created manually in a text editor to make sure the entries are sensible. Use an editor such as the built-in ee, as follows:
# ee /etc/X11/xorg.conf
Use the arrow keys to browse through the file.
  1. Make sure the Device block shows information accurately identifying your card.
  2. Similarly, make sure the display modes shown in the Screen section correspond to valid modes that you know your monitor and card can handle.
If you need to make any changes, save the file by pressing Esc and then Enter, then choosing Save Changes when you exit. When the file is configured to your satisfaction, start X11 with the following command:
# startx
Remember to press Ctrl+Alt+Backspace to kill X11 if you get put into a display mode that's unusable or that fails to achieve video sync don't risk damage to your monitor! If X11 starts up properly, it does so using a very basic desktop: the TWM window manager. This is a venerable but very lightweight desktop environment, providing the very basics in mouse-based control of window shapes and desktop utilities. In the default configuration, you get a command-line xterm window labeled login (which is tied to your X11 session exit this window and you'll drop to the command line), two more unlabeled xterm windows, and a clock. You can work in any of the terminal windows just as you would at the command line. TWM has "sloppy focus," meaning that the active window the one where your keyboard input goes is the one where your mouse pointer is; so if your typing doesn't go into the window where you expect to see it, move the mouse to point to that window and leave it there. Also note that each new program you launch, or each new window spawned by a running program, requires you to click the mouse to place its new window in a location of your choice on the screen. TWM is good for experts and ascetics, but it's a pretty miserable experience trying to make it behave like a modern desktop GUI. For that, we have a variety of excellent desktop environments to choose from: GNOME, KDE, XFce, Window Maker, and many others. If you left-click on the desktop area in TWM, a menu appears with several window-management options; two of these, at the bottom, are Restart and Exit. Note that these do not mean "restart the computer" and "exit X11"; instead, they refer specifically to TWM, and will only restart or kill the TWM process, respectively, leaving you in a bare X11 session with no window manager. Shut down X11 for now by typing exit in the login window, or by using the Ctrl+Alt+Backspace keystroke.

No comments:

Post a Comment