0186-0188.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 361 行
HTML
361 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:X Window</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=10 //-->
<!-- PAGES=0175-0194 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0183-0185.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0189-0194.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-186"><P>Page 186</P></A>
<P>Listing 10.6. continued
</P>
<!-- CODE //-->
<PRE>
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
</PRE>
<!-- END CODE //-->
<P>The line numbers in this listing have been added for your benefit. Let's look at these lines
in greater detail.
</P>
<P>Lines 4_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.
</P>
<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. For now you can use this
the way it stands.
</P>
<P>Lines 22_24 check for the xsetroot program, and if present, execute it to set the
background to a solid color, gray32.
</P>
<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.
</P>
<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.
</P>
<P>A simpler .xinitrc file to start with would be the following:
</P>
<!-- CODE SNIP //-->
<PRE>
xterm -name Console &
olvwm
</PRE>
<!-- END CODE SNIP //-->
<P>You can then enhance this .xinitrc file with what you want.
</P>
<H3><A NAME="ch10_ 14">
The Personal X Resource File
</A></H3>
<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.
</P>
<A NAME="PAGENUM-187"><P>Page 187</P></A>
<P>
<P>
<P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
NOTE
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
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.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<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.
</P>
<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:
</P>
<!-- CODE SNIP //-->
<PRE>
#ifdef COLOR
*customization: -color
#endif
</PRE>
<!-- END CODE SNIP //-->
<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.
</P>
<P>
<P>
<P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
NOTE
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
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.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<P>Note that the black-and-white color scheme of a program may be caused by the program
rather than its resources.
</P>
<P>The -xrm can be used with most X programs to override the parameters set in your
.Xresources file. The usage is
</P>
<!-- CODE SNIP //-->
<PRE>
-xrm "resource"
</PRE>
<!-- END CODE SNIP //-->
<P>Alternatively, you can use the xrdb
<filename> command to enforce any changes you have
made in <filename> that apply to your current session.
</P>
<H3><A NAME="ch10_ 15">
Using xdm
</A></H3>
<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 runlevel is attached to an X-only system (look at
/etc/inittab). All you have to do to get it working is change the default runlevel. On systems that use an
init
</P>
<A NAME="PAGENUM-188"><P>Page 188</P></A>
<P>without runlevels (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.
</P>
<H3><A NAME="ch10_ 16">
Configuration of the Window Manager
</A></H3>
<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
</P>
<UL>
<LI> olwm or
olvwm for the OPEN LOOK Window manager. (It is on the CD-ROM at
the back of this book.)
<LI> mwm for the Motif window manager, possibly the most common commercial
window manager. You have to buy it along with Motif.
<LI> twm. (It is part of the XFree86 distribution on the CD-ROM at the back of this book.)
<LI> fvwm95. (This seems to be the most popular freely available window manager and is
on the CD-ROM at the back of this book.)
</UL>
<P>I discuss mwm in greater detail in Chapter 26, "Motif Programming."
</P>
<H3><A NAME="ch10_ 17">
Compiling Programs That Use X
</A></H3>
<P>Before compiling any programs for X, please read the
GCC-HOWTO file. This file can be found in the
pub/Linux/docs/HOWTO directories of sunsite or under
/usr/doc. Many questions on compiling programs with Linux are answered here.
</P>
<P>If you have the source code for a program that uses X11, it is usually shipped with an
Imakefile instead of a Makefile.
</P>
<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.
</P>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
TIP
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
xmkmf is an abbreviation for X Make Makefile.
</BLOCKQUOTE></TD></TR>
</TABLE>
<P><CENTER>
<a href="0183-0185.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0189-0194.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?