📄 ch22.htm
字号:
while logged in as root.</P>
<P>Alternatively, you can use the initial <TT>/etc/rc.d</TT> scripts to run xdm for
you. 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 <TT>.xinitrc</TT> file for you.
<CENTER>
<H3><A NAME="Heading29<FONT COLOR="#000077">Configuration of the Window Manager</FONT></H3>
</CENTER>
<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 <TT>.xinitrc</TT> file, so look there. These are the most commonly used window
managers for Linux:
<UL>
<LI>olwm or olvwm for the OPEN LOOK window manager. (It is on the CD-ROM at the back
of this book.)
<P>
<LI>mwm for the Motif window manager, possibly the most common commercial window
manager. You have to buy it along with Motif.
<P>
<LI>twm. (It is part of the XFree86 distribution on the CD-ROM at the back of this
book.)
<P>
<LI>fvwm, which seems to be the most popular shareware window manager. (It is on
the CD-ROM at the back of this book.) There is a Windows 95 look and feel for fvwm
called fvwm95.
</UL>
<P>I discuss some window managers in greater detail in the next couple of chapters
on OPEN LOOK and Motif.
<CENTER>
<H3><A NAME="Heading30<FONT COLOR="#000077">Compiling Programs That Use X</FONT></H3>
</CENTER>
<P>Before compiling any programs for X, read the <TT>GCC-FAQ</TT> file. This file
can be found in the <TT>docs</TT> directories of <TT>sunsite</TT> and <TT>tsx-11</TT>
before any programs are compiled. Many questions on compiling programs with Linux
are answered in this FAQ. Many Linux distributions include the most relevant FAQs
in the directory <TT>/usr/doc</TT>, so you might look there first.</P>
<P>If you have the source code for a program that uses X11, it is usually shipped
with an imakefile rather than 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 <TT>X</TT> sources. Just remember the shell script <TT>xmkmf</TT>,
and you should be OK.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading31<FONT COLOR="#000077"><B>TIP:</B> </FONT><TT>xmkmf</TT> is
a abbreviation for X make makefile.
<HR>
</DL>
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading32<FONT COLOR="#000077"><B>CAUTION:</B> </FONT>The <TT>xmkmf</TT>
shell script actually runs the <TT>imake</TT> command with a set of arguments. The
most common argument is the <TT>-DUseInstalled</TT> argument. If you examine <TT>xmkmf</TT>
(look in <TT>/usr/X11/bin/</TT>), you will see that the <TT>xmkmf</TT> script is
a basic wrapper around a call to <TT>imake</TT>. It's very tempting to use <TT>imake</TT>
on a command line by itself. Do not do so. Run the <TT>imake</TT> command with the
<TT>-DUseInstalled</TT> argument if you must run <TT>imake</TT> on the command line.
If you don't use this argument, <TT>imake</TT> behaves as if it were re-creating
the X Window system on your current directory.
<HR>
</DL>
<P>Of course, before ever running <TT>xmkmf</TT>, you should read the documentation
that usually comes with such packages.</P>
<P>Run <TT>xmkmf</TT> in the directory that contains the imakefiles. If there is
a hierarchy of directories with imakefiles, you usually only have to run <TT>xmkmf</TT>
in the root directory of that hierarchy.</P>
<P>The <TT>xmkmf</TT> command builds the makefiles in all directories in the hierarchy.</P>
<P>You next should run the <TT>make</TT> command with an argument to let <TT>make</TT>
resolve its dependencies, using the following command:</P>
<PRE><FONT COLOR="#0066FF">$ make depend
</FONT></PRE>
<DL>
<DT><FONT COLOR="#0066FF"></FONT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading33<FONT COLOR="#000077"><B>TIP:</B> </FONT>Don't be afraid
if <TT>include</TT> files, such as <TT>stddef.h</TT> and <TT>varargs.h</TT>, are
not found. They are <TT>gcc</TT> proprietary header files and therefore are not in
the standard <TT>include</TT> directories.
<HR>
</DL>
<P>After that, you can <TT>make</TT> the program by running <TT>make</TT>, and you
can install your new utility (usually in <TT>/usr/X386/bin</TT>) by running this
line:</P>
<PRE><FONT COLOR="#0066FF">$ make install
</FONT></PRE>
<P>The installation of the man pages is usually done with this command:</P>
<PRE><FONT COLOR="#0066FF">$ make install.man
</FONT></PRE>
<CENTER>
<H3><A NAME="Heading34<FONT COLOR="#000077">Compiling Sources for XFree86</FONT></H3>
</CENTER>
<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 need a lot of
disk space and CPU time to do a complete build of the XFree86 system. You can find
anything you need to know for compiling XFree86 in the following files (in <TT>/usr/X386/lib/X11/etc</TT>):
<TT>INSTALL</TT>, <TT>README</TT>, and <TT>README.Linux</TT>.</P>
<P>To build a server that includes only those drivers you need, you should use the
<TT>LinkKit</TT> instead of compiling the complete system. This is a little easier
than trying to build XFree86 from scratch. The <TT>LinkKit</TT> package is too specific
and complicated and is therefore beyond the scope of this chapter.</P>
<P>You can find the documentation on how to build servers in the <TT>/usr/X386/lib/Server/VGADriverDoc</TT>
directory after installing the <TT>LinkKit</TT> package. Read <TT>/usr/X386/lib/Server/README</TT>
for a description of how to use <TT>LinkKit</TT>. This file is not included in the
standard XFree86 tar files but is part of the file that includes the <TT>LinkKit</TT>.
<CENTER>
<H3><A NAME="Heading35<FONT COLOR="#000077">Configuring fvwm</FONT></H3>
</CENTER>
<P>After you have installed Linux with X Window, chances are that you will want to
use the default window manager, fvwm, that comes with Linux. The fvwm supposedly
stands for either Free Virtual Window Manager or the Frugal Virtual Window Manager.
In the documentation, fvwm is referred to by its initials only and is conveniently
pronounced "F-V-W-M."</P>
<P>The fvwm is a good window manager that can be used in place of twm (Tom's window
manager), mwm (Motif window manager), and olvwm (OPEN LOOK virtual window manager).
This section will introduce you to the basics of configuring this window manager
for your use. You can get a lot more information specific to your X Window setup
by reading the man pages for fvwm.</P>
<P>Now there is a newer Windows 95 look-alike window manager called fvwm95. This
is included in the CD-ROM at the back of this book. If you miss Windows 95 (from
Microsoft), you can use this "Windows 95 look and feel" hack for Linux
that is available from <TT>sunsite.unc.edu</TT> in the <TT>/pub/Linux/X11/window-managers</TT>
directory. The latest version at the time of writing was <TT>fvwm95-2.0.43.tar.gz</TT>.
The tar archive includes documentation and installation instructions for this new
package. There are also detailed instructions in the package on how to convert from
fvwm to fvwm95. The configurations for your setup after conversion are then kept
in <TT>.fvwm2rc95</TT> in your home directory.</P>
<P>This chapter covers the fvwm manager that is currently used more often.</P>
<P>When it is being initialized, fvwm relies on one of two files. The first file
fvwm looks for is the <TT>.fvwmrc</TT> file in the home directory of the user. If
this <TT>.fvwmrc</TT> file is not found, fvwm looks for the default configuration
file, <TT>/usr/lib/X11/fvwm/system.fvwmrc</TT>. If neither file exists or if the
file being read is not formatted correctly, fvwm stops processing and bails out with
a list of error messages.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading36<FONT COLOR="#000077"><B>TIP:</B> </FONT>Because fvwm is
very fickle about formats in its configuration file, always keep a working backup
copy of your .<TT>fvwmrc</TT> file before making changes. This way, you will have
something to fall back on if your changes crash fvwm.
<HR>
</DL>
<P>Changes to customize your desktop can be made to either the <TT>.fvwmrc</TT> file
in your home directory or the <TT>system.fvwmrc</TT> file. If you make changes to
the system file, you will be affecting all other users on your machine who rely on
it. In general, you should copy the <TT>system.fvwmrc</TT> file to your home directory
as <TT>.fvwmrc</TT> and make changes there. The rest of this section assumes that
you are making changes to the <TT>.fvwmrc</TT> in your local directory. When you
are satisfied with your changes, you can elect to copy the <TT>.fvwmrc</TT> file
to the <TT>system.fvwmrc</TT> file. The <TT>/usr/lib/X11/fvwm</TT> directory requires
root privilege. Making the changes to <TT>system.fvwmrc</TT> is an administrative
task and is not left to individual users.</P>
<P>If you do not already have a <TT>~./.fvwmrc</TT> file, create one with the following
command:</P>
<PRE><FONT COLOR="#0066FF">$ cp /usr/lib/X11/fvwm/system.fvwmrc ~/.fvwmrc
</FONT></PRE>
<P>Now let's look at some basic components of the <TT>.fvwmrc</TT> file. These are
the basic components:
<UL>
<LI>Pop-up menu hierarchy
<P>
<LI>Actions to take on startup
<P>
<LI>Color definitions
<P>
<LI>Customization styles
</UL>
<P>These components can be found in many locations in the <TT>.fvwmrc</TT> file.
The order of appearance in the <TT>.fvwmrc</TT> file, however, is based on the criterion
that you must define an object first before you can use it.
<CENTER>
<H4><A NAME="Heading37<FONT COLOR="#000077">Pop-Up Menus</FONT></H4>
</CENTER>
<P>While running fvwm, you invoke the pop-up menus by clicking the left mouse button
on the background of the window. The default <TT>.fvwmrc</TT> file will come with
several options already set for you.</P>
<P>The best way to start is by example. An excerpt from my <TT>.fvwmrc</TT> file
is shown in Listing 22.7.
<CENTER>
<H3><A NAME="Heading38<FONT COLOR="#000077">Listing 22.7. An excerpt from an
.fvwmrc file.</FONT></H3>
</CENTER>
<PRE><FONT COLOR="#0066FF">
Popup "Applications"
Title "Applications"
Exec "&Netscape" exec /home/khusain/bin/n30/netscape &
Exec "X&V" exec xv &
Exec "X&edit" exec xedit &
Exec "X&fig" exec xfig &
Exec "Xf&m" exec xfm &
Exec "Xfilem&anager" exec xfilemanager &
Exec "X&grab" exec xgrab &
Exec "X&paint" exec xpaint &
Exec "Xsprea&d" exec xspread &
# Exec "Xxgdb" exec xxgdb &
EndPopup
</FONT></PRE>
<P>This menu shows a pop-up window with options to select commands with. The <TT>Exec</TT>
keyword tells fvwm that it has to execute a command. The string following the <TT>Exec</TT>
keyword will be displayed on the pop-up menu item. The ampersand before a character
creates a shortcut key for that command. For example, <TT>"&Netscape"</TT>
will be displayed with the N underlined. Then when the pop-up menu window is displayed,
a press of the N key (either Shift-N or Shift-n, because case does not matter) will
start Netscape from the directory <TT>/home/khusain/bin/n30</TT>. All commented lines
begin with a hash (<TT>#</TT>; see the line for <TT>xxgdb</TT>) and are ignored by
fvwm.</P>
<P>It's important that all <TT>Exec</TT>-ed applications be started in the background.
This is why there is an ampersand at the end of the Netscape command. The title parameter
sets the string that will be displayed for the pop-up menu selection list. The string
following the <TT>Popup</TT> keyword is the name of this selection. Other pop-up
menus can then refer to this menu selection with the name Applications. Look at the
middle of the code shown in Listing 22.8, in the Utilities pop-up menu, to see where
the Applications pop-up is called out.
<CENTER>
<H3><A NAME="Heading39<FONT COLOR="#000077">Listing 22.8. Calling one pop-up
menu from another.</FONT></H3>
</CENTER>
<PRE><FONT COLOR="#0066FF">
Popup "Utilities"
Title "Utilities"
Exec "Top" exec rxvt -font 7x14 -T Top -n Top -e top &
Exec "Calculator" exec xcalc &
Exec "Xman" exec xman &
Exec "Xmag" exec xmag &
Exec "Oclock" exec oclock &
Nop ""
Popup "Applications" Applications
Nop ""
Popup "Shells" Shells
Nop ""
Popup "Games" Games
Nop ""
Popup "Screensaver (a-h)" Screensaver1
Popup "Screensaver (i-z)" Screensaver2
Nop ""
Popup "Lock Screen (a-h)" Screenlock1
Popup "Lock Screen (i-z)" Screenlock2
Nop ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -