📄 rhl22.htm
字号:
<BR>
<A NAME="E68E157"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>The </B><B>.xinitrc</B><B> File</B></FONT></CENTER></H3>
<BR>
<P>To use X, you need a startup file that calls the local modifications, the window manager, and an application you want to use right after X has started. If you are using startx (or runx) to start X, this startup file is called xinitrc. There is a
standard xinitrc file, /usr/lib/X11/xinit/xinitrc, which is the traditional location for this file. The Linux file system standard places this file in /etc/X11/xinit/xinitrc in order to allow a read-only mounted /usr partition, so look in that location
first.
<BR>
<P>If you are not content with what this file does (for instance, if you want to use a different window manager), you should copy it to the file .xinitrc in your home directory. After copying the file, you can edit it. Look at the man pages for startx and
xinit for more information.
<BR>
<P>Note that both the .xinitrc and the .Xresources files must be readable and executable, so run the following commands on these files after editing them. You only have to run the chmod command once on the application.
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">$ chmod u+rx .xinitrc .Xresources</FONT></PRE>
<P>This command makes these files executable.
<BR>
<P>See Listing 22.6 for a sample .xinitrc file.
<BR>
<P>
<FONT COLOR="#000080"><B>Listing 22.6. Sample </B><B>.xinitrc</B><B> file.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080">1 #!/bin/sh
2 # $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
3 # modified by obz
4 userresources=$HOME/.Xresources
5 usermodmap=$HOME/.Xmodmap
6 sysresources=/usr/lib/X11/xinit/.Xresources
7 sysmodmap=/usr/lib/X11/xinit/.Xmodmap
8 # merge in defaults and keymaps
9 if [ -f $sysresources ]; then
10 xrdb -merge $sysresources
11 fi
12 if [ -f $sysmodmap ]; then
13 xmodmap $sysmodmap
14 fi
15 if [ -f $userresources ]; then
16 xrdb -merge $userresources
17 fi
18 if [ -f $usermodmap ]; then
19 xmodmap $usermodmap
20 fi
21 # Set the background to a dull gray
22 if [ -f /usr/bin/X11/xsetroot ]; then
23 xsetroot -solid gray32
24 fi
25 if [ -f /usr/bin/X11/xclock ]; then
26 xclock -geometry 80x80 &
27 fi
28 olvwm &
29 # fvwm &
30 xterm -e /bin/bash</FONT></PRE>
<P>The line numbers in this listing have been added for your benefit. Let's look at these lines in greater detail.
<BR>
<P>Lines 4 to 7 set the resource environment variables for the X Window installation for your system. Change these to the path of your system's X Window system distribution.
<BR>
<P>Lines 9 through 20 check for the existence of these resources and then run the appropriate program, xmodmap or xrdb, with these resources as parameters. I will cover xmodmap and xrdb in <A HREF="rhl23.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl23.htm">Chapter 23</A>, "Using Motif." For
now you can use this the way it stands.
<BR>
<P>Lines 22 to 24 check for the xsetroot program, and if present, execute it to set the background to a solid color, gray32.
<BR>
<P>The olvwm & command in line 28 starts the OPEN LOOK window manager for you. If you want to use fvwm instead of olvwm, uncomment line 29 and comment line 28 instead. The window manager must be run in the background if you have more commands following
this one.
<BR>
<P>Line 30 starts a terminal to work with. Because this is the last line in the .xinitrc file, exiting this terminal causes your X session to stop. If you want to start more xterms, you can start them from within this xterm.
<BR>
<P>A simpler .xinitrc file to start with would be the following:
<BR>
<PRE>
<FONT COLOR="#000080">xterm -name Console &
olvwm</FONT></PRE>
<P>You can then enhance this .xinitrc file with what you want.
<BR>
<BR>
<A NAME="E68E158"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>The Personal X Resource File</B></FONT></CENTER></H3>
<BR>
<P>Sometimes you won't be content with default settings for applications that don't have a configuration file of their own. You can change some of these defaults by setting X resources in the .Xresources file in your home directory.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>You should know what effects setting the resources will have on the programs you use. Read the man pages for the program and for xrdb before editing the .Xresources file. See <A HREF="rhl02.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl02.htm">Chapter 2</A>, "Types of Linux Available,"
and <A HREF="rhl25.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl25.htm">Chapter 25</A>, "Ghostscript," for more information about X resources.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>A resource file looks like an application default file. The difference is that in the resource file, resources for several applications are set. You should use the full names (Progname.Resourcename) instead of abbreviating the program name with an
asterisk. Examples of application default files can be found in the /usr/X11R6/lib/X11/app-defaults directory. The resources available for a single application are usually shown in the man pages for that application.
<BR>
<P>If you are running a color server, you might want to put the following lines into your .Xresources file if some programs start in black and white:
<BR>
<PRE>
<FONT COLOR="#000080">#ifdef COLOR
*customization: -color
#endif</FONT></PRE>
<P>If this change is made, the program foo will read both the Foo and the Foo-color application default file from /usr/X11R6/lib/X11/app-defaults. The usual behavior is for Foo only to be read.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>If you are running a color server, the preceding code definitely should be added to the system .Xresources file. You might mention that to the person or entity who maintains the program you are running.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>Note that the black-and-white color scheme of a program may be caused by the program rather than its resources.
<BR>
<P>The -xrm can be used with most X programs to override the parameters set in your .Xresources file. The usage is
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">-xrm "resource"</FONT></PRE>
<P>Alternatively, you can use xrdb <filename> command to enforce any changes you have made in <filename> apply to your current session.
<BR>
<BR>
<A NAME="E68E159"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using </B><B>xdm</B></FONT></CENTER></H3>
<BR>
<P>If you want to run X on your system all the time, you could run xdm from the system startup. xdm is preconfigured on most systems, so you should not have to edit any of the xdm configuration files. Usually a run level is attached to an X-only system
(look at /etc/inittab). All you have to do to get it working is change the default run level. On systems that use an init without run levels (run man init to see whether your system uses an init), you should look into the /etc/rc and /etc/rc.d/rc.local
files; you usually only have to remove comment signs at the beginning of a line that calls xdm. If no such line is present, you probably have a system that has no preconfigured xdm. In any event, xdm by default runs your .xinitrc file for you.
<BR>
<BR>
<A NAME="E68E160"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Configuration of the Window Manager</B></FONT></CENTER></H3>
<BR>
<P>Window managers are a user- and site-specific issue. Several window managers are available for Linux. The configuration of one window manager is quite different from that of another. The window manager used in the configuration is usually explained in
your .xinitrc file, so look there. The most commonly used window managers for Linux are
<BR>
<UL>
<LI>olwm or olvwm for the OPEN LOOK Window manager. (It is on the CD at the back of this book.)
<BR>
<BR>
<LI>mwm for the Motif window manager, possibly the most common commercial window manager. You have to buy it along with Motif.
<BR>
<BR>
<LI>twm. (It is part of the XFree86 distribution on the CD at the back of this book.)
<BR>
<BR>
<LI>fvwm. (This seems to be the most popular freely available window manager and is on the CD at the back of this book.)
<BR>
<BR>
</UL>
<P>I discuss some window managers in greater detail in the next few chapters on OPEN LOOK and Motif.
<BR>
<BR>
<A NAME="E68E161"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Compiling Programs That Use X</B></FONT></CENTER></H3>
<BR>
<P>Before compiling any programs for X, please read the GCC-FAQ file. This file can be found in the pub/Linux/docs/faqs directories of sunsite. Many questions on compiling programs with Linux are answered in this FAQ. Many Linux distributions include the
most relevant FAQs in the directory /usr/doc, so you might look there first.
<BR>
<P>If you have the source code for a program that uses X11, it is usually shipped with an Imakefile instead of a Makefile.
<BR>
<P>Imakefiles are files that create Makefiles for your system. Discussing Imakefiles is beyond the scope of this book; however, you will have to work with Imakefiles if you work at all with X sources. Just remember the shell script xmkmf, and you should be
okay.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>xmkmf is an abbreviation for X Make Makefile.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>The xmkmf shell script actually runs the imake command with a set of arguments. The most common argument is the -DUseInstalled argument. If you examine xmkmf, (look in /usr/X11R6/bin/); you will see that the xmkmf script is a basic wrapper around a
call to imake. It's very tempting to use imake on a command line by itself. Do not do so. Run the imake command with the -DUseInstalled argument if you must run imake on the command line. If you do not use this argument, imake will behave as if it were
re-creating the X Window system on your current directory.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>Of course, before ever running xmkmf, you should read the documentation that usually comes with such packages.
<BR>
<P>Run xmkmf in the directory that contains the Imakefile. If there is a hierarchy of directories with Imakefiles, you usually only have to run xmkmf in the root directory of that hierarchy.
<BR>
<P>The xmkmf command builds the Makefiles in all directories in the hierarchy.
<BR>
<P>Then you should run the make command with an argument to let make resolve its dependencies, using the following command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">$ make depend</FONT></PRE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Don't be afraid if include files, such as stddef.h, varargs.h, and so on, are not found. They are gcc proprietary header files, and therefore not in the standard include directories.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>After that, you can make the program by running make, and you can install your new utility (usually in /usr/X11R6/bin) by running this line:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">$ make install</FONT></PRE>
<P>The installation of the man pages is accomplished by running
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">$ make install.man</FONT></PRE>
<BR>
<A NAME="E68E162"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Some Common Problems</B></FONT></CENTER></H3>
<BR>
<P>Some of the problems you might see when you work with XFree86 are outlined in the following list.
<BR>
<UL>
<LI>No windows—all you get is a gray background and no windows. This is due to running without a window manager. Running X only starts the X server, not the window manager. You should use a script shown earlier in startx in <A HREF="rhl21.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl21.htm">Chapter
21</A>, "Installing X Window on Linux."
<BR>
<BR>
<LI>Your Logitech serial mouse does not work. The keyword Logitech is reserved for older Logitech serial mice. Use the keyword MouseMan (or Microsoft) for newer mice. Logitech serial mice plugged into a PS/2 port require the keyword PS/2.
<BR>
<BR>
<LI>You get errors about not finding any font files. First check the XF86Config file to see whether the directories in the font path are named correctly and contain fonts. If they are correct, run mkfontdir in each of those directories to set them up for
use with X.
<BR>
<BR>
<LI>After leaving X, your screen fonts are not restored. This is a known bug with some servers. There are utilities called runx or restoretext included with svgalib that can help you in most cases. You can get them from sunsite.unc.edu in the file
/pub/Linux/libs/graphics/svgalib-1.2.10.tar.gz.
<BR>
<BR>
<LI>You will have some problems on uncommon, extremely new, or extremely old cards. This is what you have to live with when you are dealing with freeware.
<BR>
<BR>
<LI>The server dies with the message Cannot find a free VT. XFree86 needs a free virtual terminal (VT) on which to run. So if you have put a getty process on every virtual console in your /etc/inittab, XFree86 is not able to start. The common practice is
to leave /dev/tty8 (for kernel messages) and /dev/tty7 (for XFree86) free of a getty process.
<BR>
<BR>
</UL>
<P>This is not an exhaustive list. Please read the HOWTO documents in /usr/docs on the CD-ROM for more information about other video card problems that are too specific to list here.
<BR>
<BR>
<A NAME="E68E163"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Compiling Sources for XFree86</B></FONT></CENTER></H3>
<BR>
<P>You do not typically want to compile sources for XFree86 unless you really want to make changes to the sources because something is not working. You will need a lot of disk space and CPU time to do a complete build of the XFree86 system. Anything you
need to know for compiling XFree86, you can find in the following files (in /usr/X11R6/lib/X11/etc): INSTALL, README, and README.Linux.
<BR>
<P>Note that you should not compile XFree86 to get rid of hardcoded restrictions (on the maximal pixel clock, for example) because without these restrictions, your hardware will probably break down.
<BR>
<P>To build a server that includes only those drivers you need, you should use the LinkKit instead of compiling the complete system. This is a little easier than trying to build it from scratch. The LinkKit package is specific and complicated and is
therefore beyond the scope of this chapter.
<BR>
<P>Read /usr/X11R6/lib/Server/README for a description of how to use LinkKit. This file is not included in the standard XFree86 tar files but is part of the file that includes the LinkKit.
<BR>
<P>For adding drivers to the SVGA servers, you need the LinkKit only.
<BR>
<P>The documentation on how to build servers can be found in the /usr/X11R6/lib/Server/VGADriverDoc directory after installing the LinkKit package.
<BR>
<BR>
<A NAME="E68E164"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>
<BR>
<P>This chapter covered the topic of configuring the XFree86 system. After reading this chapter, you should have an idea of how to set up your XF86Config file to generate your X environment. Just remember to start with the basic configuration settings for
VGA cards and then make enhancements. Keep backups of your work and do not change the video settings unless you know what you are doing. If nothing works despite your best efforts, you have the recourse of knowing where to look for answers in FAQs,
newsgroups, and FTP sites on the Internet for HOWTO and other documents on Linux.<A NAME="I2"></A>
<P ALIGN=LEFT>
<A HREF="rhl21.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl21.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>
<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="rhl23.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl23.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -