412-414.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 136 行

HTML
136
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Installing and Configuring XFree86</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=22//-->

<!--PAGES=412-414//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="409-411.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch23/415-419.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading19"></A><FONT COLOR="#000077">Testing XFree86 Configurations</FONT></H4>

<P>Now that the <TT>Xconfig</TT> or <TT>XF86Config</TT> file is completed, it&#146;s time to take the plunge and start XFree86. Use the command <TT>startx</TT> and the X startup script should load all the requisite drivers and daemons, clear the screen, then show the basic X Window session. If XFree86 can&#146;t load, it will usually display error messages as part of the termination process. Check these messages to determine whether there&#146;s any hint as to the problem. Usually, XFree86 runs into supported video mode problems. (For those used to using UNIX on other systems, <TT>startx</TT> is a front-end utility to <TT>xinit</TT>, usually used to start X.)</P>

<P>If you can&#146;t get XFree86 running quickly, the easiest debugging method is to step all the configuration information to the lowest denominator, such as a simple VGA system. If that works, then you can step up to more complex resolutions and configurations. This usually helps isolate the cause of the problems. If the generic VGA drivers don&#146;t work, then a configuration problem is usually the cause. Check the configuration files carefully.</P>

<H3><A NAME="Heading20"></A><FONT COLOR="#000077">The .xinitrc File</FONT></H3>

<P>The <TT>.xinitrc</TT> is a startup file (similar to the <TT>.profile</TT> or <TT>.cshrc</TT> startup files for the shells) for X. It usually includes any local modifications to the configuration defined in the <TT>Xconfig</TT> or <TT>XF86Config</TT> files, as well as instructions for starting specific applications or window managers when XFree86 starts. If you use either the <TT>startx</TT> or <TT>runx</TT> commands to start XFree86, the <TT>.xinitrc</TT> is renamed without the period (so it would be called <TT>xinitrc</TT>).</P>

<P>The system&#146;s <TT>xinitrc</TT> file is usually kept as <TT>/usr/lib/X11/xinit/xinitrc</TT> or in <TT>/etc/X11/xinit/xinitrc</TT>. The latter path is more common with XFree86 and Linux, while the former is the path for X. (Linux places the file in the <TT>/etc/X11</TT> directory structure instead of <TT>/usr/lib</TT> because some Linux installations prefer to mount the <TT>/usr</TT> directories as read-only and because sometimes they reside on a CD-ROM.)</P>

<P>The system&#146;s default <TT>.xinitrc</TT> file can be overridden by placing a copy in your home directory. When XFree86 starts, it first checks your home directory for the <TT>.xinitrc</TT> file, and then reads the default startup file if one isn&#146;t found. If you want to customize the behavior of the XFree86 session, copy the system file to your home directory and edit it with any editor. There are man pages for <TT>startx</TT> and <TT>xinit</TT> that explain some of the details of the startup file.</P>

<P>An example of a <TT>.xinitrc</TT> file is shown as follows. This is the default startup file from a straightforward XFree86 installation. The file has been cut into smaller sections so each subsection can be examined in a little more detail. The first subsection deals with setting paths:</P>

<!-- CODE SNIP //-->

<PRE>

userresources=&#36;HOME/.Xresources

usermodmap=&#36;HOME/.Xmodmap

sysresources=/usr/X11R6/lib/X11/xinit/.Xresources

sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

</PRE>

<!-- END CODE SNIP //-->

<P>These paths are usually set up in the XFree86 software, but you should check them to make sure they are valid. Remember to follow links if they exist to other directories. These variables are all that is required for XFree86.

</P>

<P>The next subsection checks for the existence of some system resources and performs actions based on the check. Most, if not all, of these checks will not need to be modified unless you have very special requirements for your X session.</P>

<!-- CODE //-->

<PRE>

# merge in defaults and keymaps



if [ -f &#36;sysresources ]; then

  xrdb -merge &#36;sysresources

fi



if [ -f &#36;sysmodmap ]; then

  xmodmap &#36;sysmodmap

fi



if [ -f &#36;userresources ]; then

  xrdb -merge &#36;userresources

fi



if [ -f &#36;usermodmap ]; then

  xmodmap &#36;usermodmap

fi

</PRE>

<!-- END CODE //-->

<P>The final subsection in the <TT>.xinitrc</TT> file runs the <TT>setroot</TT> program, if present, to set the background color (in this case, to steel blue). Finally, the <TT>fvwm</TT> window manager is executed and starts your session:</P>

<!-- CODE SNIP //-->

<PRE>

# start some nice programs

xsetroot -solid SteelBlue

fvwm

</PRE>

<!-- END CODE SNIP //-->

<P>If you want to use another window manager, such as Motif&#146;s <TT>mwm</TT> manager, change the last line in this subsection. Make sure that the window manager file is in the search path, so the startup routines can find it.</P>

<P>If you want to create an <TT>xterm</TT> session from within the <TT>.xinitrc</TT> file (you will need an <TT>xterm</TT> or other utility to start other tasks within XFree86), add the following line:</P>

<!-- CODE SNIP //-->

<PRE>

xterm -e /bin/bash

</PRE>

<!-- END CODE SNIP //-->

<P>In this case, the <TT>bash</TT> shell is invoked within the <TT>xterm</TT>. You can, of course, use any shell you want.</P>

<P>If you create <TT>.xinitrc</TT> files for your own use, place them in your home directory. You can, for example, use a <TT>.xinitrc</TT> file like this:</P>

<!-- CODE SNIP //-->

<PRE>

#!/bin/sh



xterm -fn 7x13bold -geometry 80x32&#43;10&#43;10 &

xterm -fn 7x13bold -geometry 80x32&#43;30&#43;50 &

oclock -geometry 70x70-7&#43;7 &

xsetroot -solid SteelBlue &

exec fvwm

</PRE>

<!-- END CODE SNIP //-->

<P>This starts two <TT>xterms</TT> and the clock and places them on the desktop, then sets the background color to steel blue and finally starts the desktop manager. Two important notes: The last command in the script is preceded by the <TT>exec</TT> command and the last command is not sent to background. If you send the last command to background or forget the <TT>exec</TT> command, X starts up, and then immediately shuts down!</P>

<H3><A NAME="Heading21"></A><FONT COLOR="#000077">Summary</FONT></H3>

<P>All of the previous steps will help you set up XFree86 properly, and after following them your XFree86 session should start up without a problem. The specifics of working with X are beyond the scope of this book. If you are not sure how to use X, check the documentation files that came with the release or consult a user-oriented book.

</P>

<P>However, if you followed the steps outlined previously, your X system should now be functional and you can start working with the X system as your primary interface to Linux. After you&#146;ve worked in X, it&#146;s hard to go back to character-based terminals!</P>

<P>From here, there are a number of chapters that you can go to that are related to this topic:</P>

<DL>

<DD>Wabi, a way to run Windows applications under Linux, is discussed in Chapter 23, &#147;Wabi.&#148;

<DD>Ghostscript, which lets you see PostScript files onscreen and send them to the printer, is discussed in Chapter 24, &#147;Ghostscript and Ghostview.&#148;

<DD>Programming under Linux is discussed in Part V, starting with Chapter 25, &#147;<TT>gawk</TT>.&#148;

<DD>System administration is discussed in Part VI, starting with Chapter 32, &#147;System Administration Basics.&#148;

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="409-411.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch23/415-419.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?