Your Personal .xinitrc File


Your Personal .xinitrc File

Individual users don't have to worry about the configuration of the X Server; it's handled at the root level of the system, running as a daemon when queried by clients (window managers). The window managers are user processes, and each user has the ability to choose a window manager to suit his or her taste, regardless of the hardware-limited resolutions you've defined in the xorg.conf file.

Each user controls how his X11 session looks and acts using a shell script file in his home directory called .xinitrc. One of the most common setup attributes controlled by this file is which window manager is to be invoked to handle the client end of X11's clientserver architecture during your X session. You also can use this file to control which applications start automatically every time you run X11, the background color of the screen, and the display of a background image. Each of these operations involves making changes to your personal .xinitrc file, as you learn in the sections that follow.

Changing the Window Managers

Many window managers are available in the x11-wm category of the FreeBSD ports tree or packages. One popular window manager only briefly mentioned previously is Blackbox, which is shown in Figure 7.1. See Chapter 16, "Installing Additional Software," for information on how to work with the FreeBSD ports collection.

Figure 7.1. Blackbox is a very small and fast window manager. It contains few frills and takes up very few system resources.


Blackbox is an ideal minimal window manager for users who don't want the window manager to get in the way. It is also ideal for systems that are low on resources. Blackbox is a common window manager used on servers. However, the instructions in this section apply to any window manager you install.

Note

KDE and GNOME both behave somewhat differently from regular window managers. If you want to invoke KDE when you run startx, instead of using the KDM login manager, use this line in .xinitrc:

exec startkde


For GNOME, use the following:

/usr/X11R6/bin/gnome-session



After you have installed a new window manager from the ports or packages, you must edit your personal .xinitrc file to use it. Open the .xinitrc file located in your home directory in your favorite text editor. If the file does not already exist, it will be created.

In this case, all you want to do is tell X11 what window manager to use, so you only need to add one line to the file. For Blackbox, here's the line to add:

exec blackbox


Each window manager has its own executable name; look in the pkg-plist file in any window manager's port directory to find out what the executable is called, and use it in place of blackbox here. After you have added the appropriate exec command to the .xinitrc file, save the file and exit the editor; the next time you start X11, you will be placed in the new window manager.

Configuration of window managers other than Window Maker (discussed in Chapter 5) is beyond the scope of this book. See the web page for your chosen window manager for more information; the website is usually listed in the port's pkg-descr file. (In the case of Blackbox, see http://blackboxwm.sourceforge.net/).

Note

Many other window managers are available for use with X11, and can be installed from the FreeBSD ports collection under the x11-wm directory.

For more information, including screen shots of the more popular window managers, see http://www.xwinman.org.


Starting Applications Automatically

Remember that .xinitrc is a shell script, executed at launch time when you run startx. That means you can include anything in it that you want executed whenever you start X11, including certain X applications such as xterm windows or commonly used productivity apps.

Any applications that you want to start automatically should be added before the window manager is invoked, and should end with an ampersand character (&). (Note that there should be a space before the ampersand.) This way, they start in the background and detach from the shell executing the script, allowing it to proceed to the next command. If you don't end each command with an ampersand, it will start in the foreground, blocking the script from ever reaching and launching the window manager.

Here is an example of an .xinitrc file that starts an X terminal window and an X clock along with the Blackbox window manager:

xterm & xclock & exec blackbox


Many of the programs you can execute within an X session are instrumented with options that let you define exactly where and how they appear. For example, to specify an xterm window of 80 columns by 25 lines, positioned at 100 pixels from the left edge and 50 from the top, use this line:

xterm -geometry 80x25+100+50 &


Many other X11 programs can be invoked with similar arguments; see their man pages, usually under the -geometry option, for details.

Setting a Background Color or Background Image

Many window managers and desktop environments such as Window Maker and GNOME have the built-in capability to set their own background colors or background images. However, some of the simpler window managers, such as FVWM and wm2, do not. You can set the background color or background image by calling external programs from the .xinitrc file, as explained in the following subsections.

Setting the Background Color

By default, X11 has a rather ugly checkered background that seems as though it's designed to be as hard on the eyes as possible. The program xsetroot allows you to set the background color to a solid color or to a tiled bitmap from an image. There is a text file that lists all the available named colors located in /usr/X11R6/lib/X11/rgb.txt. Here is an example of how the background color can be set to a solid color:

xsetroot -solid ForestGreen


Try typing this command from an xterm window to set the background to forest green.

If you want this change to be permanent, you can add this command to your .xinitrc file before the window manager starts. For example, the following line will set the background color to forest green and then start the twm window manager:

xsetroot -solid ForestGreen & exec twm


The color you use must be a valid color that is listed in the rgb.txt file, and if the color has a space in it, the name of the color must be enclosed in quotation marks.

In addition to setting the background color or pattern of the desktop, xsetroot can also change the appearance of the mouse pointer. See the man page for xsetroot for details on how to configure bitmapped backgrounds and also how to change the mouse pointer using a custom bitmap.

You can create your own bitmaps to use as the background and as the mouse pointers with the bitmap program, which is installed as part of X11. Figure 7.2 shows the bitmap program.

Figure 7.2. The bitmap program, which can be used to create bitmaps for use as background patterns and mouse pointers with xsetroot.


Configuring a Background Image

X11 does not come with any program that allows you to set a full-size "wallpaper" image in your desktop background. However, there is an image-viewing program called xv that is traditionally used for this task. xv is available in the ports collection under the graphics directory. Figure 7.3 shows xv running in interactive mode.

Figure 7.3. xv can do far more than just set the background image in X11. It is also a fullfeatured image viewer that can be used interactively.


xv supports most common image formats, including GIF, JPEG, BMP, and PNG, and you can use a picture in any one of these formats as a background image.

The following command is an example of how xv can be used to load an image as a background image for X11:

xv -root -quit /hone/btman/images/myimage.jpg


This command tells xv to load the image myimage.jpg onto the root window (which is the background of the window manager). It also tells xv that it should quit as soon as it has loaded the image. (This gets around the need to append an ampersand to the command line if you include it in your startup script.)

In order to have this image loaded as the background each time you start X11, you could do something like the following in your .xinitrc file:

xv -root -quit /home/foobar/images/myimage.jpg exec twm


Some of the other options you may want to use with xv when using it to load background images include -max, which will cause the image to be resized and take up the entire available screen size, and -maxspect, which will cause the image to be resized to take up the entire available screen size within the limits of maintaining the proper aspect ratio of the image.




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net