.H2 "Customizing X"
.X "customizing X"
.X "X, customizing"
.X ".xinitrc"
\fIstartx\fP\| looks for a file called \fI.xinitrc\fP\| when it starts up.  This
file typically contains commands for starting up X clients such as terminal
windows and a window manager If you don't have this file, you get a single
\fIxterm\fP\| window without a frame, as in figure \*[vanilla-X].
.br
.DF
.PIC images/empty-x.ps 4i
.Figure-heading "Vanilla X display"
.Tn vanilla-X
.DE
.X "window manager"
.X "xdm, window manager"
.X "window manager, xdm"
.X "twm, window manager"
.X "window manager, twm"
.X "fvwm2, window manager"
.X "window manager, fvwm2"
Here you have a single \fIxterm\fP\| window in the top left corner.  You can't
move it, you have no menus.  To make life worth living, you need at least a
\fIwindow manager\fP, a program which controls other windows on the display.  If
you start X from \fIxdm\fP, you will get the \fItwm\fP\| window manager and a
default environment.  \fItwm\fP\| is a pretty basic window manager.  In this
example, I use \fIfvwm2\fP, which has more features than \fItwm\fP.
.P
.X "fvwm95, window manager"
.X "window manager, fvwm95"
A large number of window managers are available for X11.  I prefer a relatively
sober looking manager, but there are many more with other features.  You can get
a good overview at \fIhttp://www.plig.org/xwinman/\fP\|.  If you like
Microsoft's ``Windows 95'' environment, you might prefer \fIfvwm95\fP, which is
similar.  Before you do, however, consider the advantages of other window
managers: Microsoft's environment does not scale well.
.P
You can start a window manager from a shell prompt, but it's easier to put the
invocation in the \fI.xinitrc\fP\| file.  A simple \fI.xinitrc\fP\| might be:
.Dx
xhost presto bumble gw							\fIallow access from other hosts\fP\|
xrdb -load .Xdefaults							\fIload default settings\fP\|
xmodmap -e 'keysym Alt_L = Meta_L Meta_L'				\fIremap keys for Emacs\fP\|
xterm -s -sl 256 -sb -ls -j -rw -geometry 100x55 &		\fIstart xterm left\fP\|
xterm -s -sl 256 -sb -ls -j -rw -geometry 100x55-0+0 &	\fIand right\fP\|
xearth &										\fIstart a root background\fP\|
emacs -name "grog emacs"  -geometry 100x55-0+0 -font 6x13& \fIand biff at the bottom\fP\|
xbiff -geometry +450-0 -fg green -bg black&
fvwm2											\fIstart fvwm\fP\|
.De
This file performs the following functions:
.Ls B
.LI
.X "xhost, command"
.X "command, xhost"
The \fIxhost\fP\| line allows connections from all systems in the Internet.  In
the interests of security, you will probably want to limit the systems to your
local network.  Check the man page \fIxhost(1)\fP\| for how to do this.
.LI
.X "xrdb, command"
.X "command, xrdb"
The \fIxrdb\fP\| line loads your local preferences.  See the man page
\fIX(1)\fP\| for more details.
.LI
.X "xmodmap, command"
.X "command, xmodmap"
The \fIxmodmap\fP\| invocation sets the \fBAlt\fP key to perform the \fBMeta\fP
function for \fIEmacs\fP\|.  If this doesn't say anything to you, don't worry.
You'll see more of it when you get to know \fIEmacs\fP.
.P
The two \fIxterm\fP\| lines start two \fIxterm\fP\|s, one on the left of the
screen, one on the right.  The \f(CWgeometry\fP keyword determines this: they
have 55 lines of 100 characters each, suitable for a standard 1024x768 display.
If your display is larger, you can expand the size of these windows to
advantage.
.LI
.X "xearth, command"
.X "command, xearth"
The invocation of \fIxearth\fP\| starts a program which updates the \fIroot
window\|\fP\*F
.FS
The root window is the background on which the other windows are displayed,.
.FE
.X "screen saver"
with a current view of the world.  In Microsoft circles, this might be called a
\fIscreen saver\fP.
.LI
\fIEmacs\fP\| takes a relatively long time to start, so it's a good idea to
start one when you start X, and leave it running.
.LI
.X "xbiff, command"
.X "command, xbiff"
\fIxbiff\fP\| is a little program which shows a picture of a US-style mailbox.
When mail arrives, it changes colour, beeps, and raises the flag.
.LI
.X "fvwm2, command"
.X "command, fvwm2"
Finally, we start the window manager, \fIfvwm2\fP.  As noted above, we don't
specify an ampersand (\f(CW&\fP) at the end of this command, so that the
\&\fI.xinitrc\fP\| script does not complete.  If you stop the window manager,
however, the script will complete, and the X session will stop.  We'll look at
what we can do with \fIfvwm2\fP\| in more detail below.
.Le
.DF
.PIC images/base-x.ps 4i
.Figure-heading "Typical X display with \fIfvwm2\fP"
.Tn base-display
.ft R\" The figure heading above screws things up
.DE
.P
.X ".xinitrc"
You'll find this \fI.xinitrc\fP\| file on the installation CD-ROM
\fI\*[skelc]/scripts/.xinitrc\fP.  On page \*[install-desktop] we'll see how to
install this and the other files I describe in this chapter.
.P
.X "Netscape, command"
.X "command, Netscape"
Now, when you start X, you will be given a somewhat better looking screen.
After opening a \fINetscape\fP\| window and iconifying it and one of the
\fIxterm\fP\| windows, it might look like figure \*[base-display].  Here we see
a Netscape window on the right and four icons:
.Ls B
.LI
.X "mutt, command"
.X "command, mutt"
On the left are two \fIxterm\fP\| icons.  The first has the name
(\f(CWyvonne@presto\fP: it has been truncated to fit the box) and a small
picture.  The second has the name \f(CWmutt\fP, indicating that it is running
the \fImutt\fP\| mail reader.
.LI
.X "StarWriter, command"
.X "command, StarWriter"
Underneath the \fIxterm\fP\| icons is a \fIStarWriter\fP\| icon.  The name of
this icon has been truncated to fit.
.LI
.X "Lehey, Yvonne"
.X "emacs, command"
.X "command, emacs"
On the right is an \fIEmacs\fP\| icon, the figure of a gnu.  The name
\f(CWyvonne\fP is the name of the user, not the program.
.Le
.X "fvwm2, window manager"
.X "window manager, fvwm2"
You'll notice that some of the names in the icons have been truncated.  This is
because the names can get \fIvery\fP\| long.  The text on a \fINetscape\fP\|
icon is the name on the title, which can be over 100 characters long.  If this
text were in the icon, it would take up half the width of the screen.
\fIfvwm2\fP\| makes a compromise: the text expands to full size when you run the
mouse cursor over the icon.
.P
In addition, we can see a couple of nested menus.  We'll look at them later.
.H2 "Navigating the desktop"
If you're used to Microsoft Windows, X may seem strange to you at first.  On the
one hand, you can recognize parallels, but on the other hand there are enormous
differences.  One of the most obvious things is the layout of the screen.  The
Microsoft desktop is not really suited to a large number of objects on the
screen.  As I write this, I have a total of 28 windows open on the
screens\(emthis does not scale well with Microsoft.
.P
.X "icon"
One similarity is that you can \fIiconify\fP\| windows: when you don't need
them, you can reduce them to a small symbol, as we saw in Figure
\*[base-display].  One of the consequences of this is that you may want smaller
icons.  Do you really need a picture of a terminal for each of 10 different
\fIxterm\fP\|s?  Maybe just the bar beneath would do.  It's your choice, but you
have the choice.
.P
You'll also notice that the windows have much more text in them than in a
Microsoft environment.  This is not simply primitive: you can do more things
with text.  Compared to Microsoft, an X environment uses the keyboard more and
the mouse less.  When you do use the mouse, you'll find that there are many more
ways to use it.  Although an X mouse should have at least three buttons,\*F
.FS
X supports up to 5 mouse buttons.  No, I've never seen a mouse with more than
three buttons.
.FE
many operations require the keyboard as well.  In addition, the function of the
mouse depends on where the cursor is positioned at the time.  We'll look at that
in the next section.
.H3 "Mouse menus"
.X "menus, mouse"
.X "mouse, menus"
.X "fvwm, window manager"
.X "window manager, fvwm"
\fIfvwm\fP\| and X distinguish several places on the screen:
.Ls B
.LI
.X "root window"
.X "window, root"
The \fIroot window\fP\| is the ``background'', the window that is left behind
when all the other ones are closed or iconified.  You can't use it for much, you
can't iconify it, and you can't put it on top of other window.  Typically you'll
display some pattern or picture on it.  In figure \*[base-display] we display a
map of the world on it.
.LI
.X "icon"
We've already seen an \fIicon\fP\|: it's a small symbol or picture representing
a window which is not currently being displayed.
.LI
.X "window"
.X "netscape, command"
.X "command, netscape"
.X "emacs, command"
.X "command, emacs"
A \fIwindow\fP\| is a unit of display.  You might think of a window as equal to
a process, but this isn't correct.  For example, \fINetscape\fP\| and
\fIEmacs\fP\| frequently display more than one window at a time.
.LI
.X "window, frame"
Windows typically have a \fIframe\fP, which contains a number of elements:
.LI
.X "window, title"
.X "window, buttons"
The \fItitle\fP\| is at the top of the window, and typically contains a text
identifying the window and possibly some \fIbuttons\fP\| which provide mouse
functions.
.LI
.X "fvwm, window manager"
.X "window manager, fvwm"
.X "window, sides"
\fIfvwm\fP\| treats the \fIsides\fP\| of the frame separately from the corners.
We'll see the difference in the tables below.
.LI
Finally, an \fIfvwm\fP\| frame may have up to 10 buttons, which \fIfvwm\fP\|
numbers 0 to 9.
.Le
You can see the typical \fIfvwm\fP\| border in example \*[base-display]. The
most important part is the title bar:
.PIC "images/titlebar.ps" 4i
.P
There are a total of three fields, called \fIbuttons\fP, on the title bar: one
on the left and two on the right.  If you position the mouse cursor on the left
button and press any any mouse button, you will get a menu:
.PIC "images/windowops.ps" .7i
.sp 1v
.Figure-heading "Window Operations Menu"
.Tn window-ops
.P
This looks familiar to Microsoft users, but in time, you will find that this
menu is less useful that it appears, since you can perform most functions
without a menu.
.P
.X "icon"
There are two buttons on the right of the title bar.  The left-hand button is
the \fIiconify\fP\| button.  If you click here with any mouse button, the window
will be \fIiconified\fP\|: it will disappear and be replaced by a small symbol
or \fIicon\fP, such as the ones on the left and bottom of figure
\*[base-display].  Iconification frees up screen area, but it doesn't stop or
suspend process execution.  If you want to stop a program, you should either
exit the application or close the window.  It's preferable to exit, since the
application is more likely to perform its housekeeping before stopping.
.P
.X "window, maximize"
The right-hand button is the \fImaximize\fP\| button.  If you click here with
any mouse button, the window will be expanded to fill the screen.  If you click
again, the window will be returned to its former size and position.
.P
Pressing mouse buttons elsewhere performs other functions.  For example, when
you move the mouse cursor to one of the corners, it changes shape to a corner
with an arrow.  This cursor shape indicates that you can extend the window in
that direction by keeping the mouse button down and dragging the border.
.P
.X ".fvwm2rc"
In most windows, the mouse keys will produce an application-specific menu.  By
convention, however, combinations of the mouse key and the \fBAlt\fP key are
interpreted by the window manager even when the cursor is in a window.  For
example, with the sample \fI.fvwm2rc\fP\|, \fBAlt-Mouse2\fP (the \fBAlt\fP key
and the middle mouse button) iconifies the window.
.P
In the next few sections, we'll look at all the mouse functions:
.H3 "Mouse key functions on the root window"
On the root window, the mouse keys are used only to produce menus.  Table
\*[root-mouse] gives an overview.
.Df
.TB "Mouse key functions on the root window"
.TS H
center,box,tab(#) ;
| lfCWp9| lf(B)p9 | lw61 | .
\fR\s10Mouse
\^\fR\s10Key#\s10\fRKeyboard#Function
=
.TH
.X "xterm, command"
.X "command, xterm"
1##T{
Produce a menu of \fIxterm\fP\|s for the left side of the screen.  This is the
menu \fILeftHosts\fP.
T}
2##T{
Produce a menu of other applications, the menu \fIApplications\fP\| 
.X "Applications, menu"
T}
3##T{
Produce a menu of \fIxterm\fP\|s for the right side of the screen.  This is the
menu \fIRightHosts\fP.
.X "RightHosts, menu"
T}
1#Shift#T{
Produce the \fIControl\fP\|
.X "Control, menu"
menu.  This menu includes various control
functions.  This is the left-hand of the menus displayed in figure
\*[base-display].
T}
2#Shift#T{
Display a list of the active windows.  Selecting a window will deiconify it if
necessary and bring it to the top of the screen (in other words, no other window will
cover it).
T}
3#Shift#T{
Bring up the ``Window operations'' menu on page \*[window-ops-page].
T}
.TE
.Tn root-mouse
.DE
.sp 1.5v
It's desirable for some menus to be independent of the position on the screen.
That way, you don't have to look carefully before selecting them.  To ensure
that they don't clash with anything else, select all of them with the key
combination \fBShift-Alt\fP:
.Df
.TB "Position-independent mouse key functions"
.TS H
center, box,tab(#) ;
| lfCWp9| lf(B)p9 | lw61 | .
\fR\s10Mouse
\^\fR\s10Key#\s10\fRKeyboard#Function
=
.TH
1#Shift-Alt#T{
Produce the \fIControl\fP\|
.X "Control, menu"
menu.  This menu includes various control
functions.  This is the left-hand of the menus displayed in figure
\*[base-display].
T}
2#Shift-Alt#T{
Display the \fIApplications\fP\|
.X "Applications, menu"
menu.
T}
3#Shift-Alt#T{
Move the current window.  This doesn't work on the root window.
T}
.TE
.sp 1.5v
.DE
.H3 "Use of colour"
.X "colour, in X"
You'll find that your X display doesn't look as brightly coloured as, say, a
Microsoft desktop.  In particular, \fIxterm\fP\| is monochrome black on pale.
If you want \fIxterm\fP\| to display in colour, you need two things:
.Ls N
.LI
Change the \f(CWTERM\fP environment variable from \f(CWxterm\fP to
\f(CWxterm-color\fP.  This enables the control sequences which \fIxterm\fP\|
uses to display in colour.
.LI
You need applications which display in colour.  The \fImutt\fP\|
.X "mutt, command"
.X "command, mutt"
mail reader will do this\(emsee \*[chemail], page \*[mutt], for further details.
So will some programs in the Ports Collection, such as \fIcolorls\fP,
.X "colorls, command"
.X "command, colorls"
a version of \fIls\fP\| which displays different kinds of files in different
colors when you supply it the \f(CW-G\fP option.
.Le


.H2 "Installing the sample desktop"
.Pn install-desktop
.X "install-desktop, script"
You'll find all the files described in this chapter on the first CD-ROM
(Installation CD-ROM) in the directory \fI\*[skelc]\fP.  Remember that you must
mount the CD-ROM before you can access the files\(emsee page \*[mount] for
further details.  The individual scripts are in the directory
\fI\*[skelc]/scripts\fP, but you'll probably find it easier to install them with
the script \fIinstall-desktop\fP:
.Dx
# \f(CB/cdrom\*[skelc]/scripts/install-desktop\fP
.De
The sample desktop uses a number of packages from the Ports Collection.  Look at
the file \fI\*[skelc]/scripts/install-desktop\fP\| for more details.


