The X Window System, when deployed, functions as a server. Just so you know what that is, a server application (which differs from what you may be currently using as a "client") runs and provides resources for other programs and system functions.
When a client wants to make use of the X Window System display and change settings, the client will make a request to the server to make such changes.
There is a lot to learn about X, and because there are so many versions, it's hard to cover all of them in one lesson. Because of this, your homework assignment is to follow this lesson as closely as you can, and after you complete it, if you want to learn more about your version of the X Window System, search www.google.com/linux and www.x.org for additional information. Starting the X Window SystemWe're now ready to start X! Let's begin. Starting the X Window System is easy. To start X, you only need to type commands at the shell prompt. First, make sure you are at the shell prompt, logged in and ready to go. You may already be in the X Window System; if this is the case, close out of it and reopen it to get the experience of loading it. Please note: If you are doing this at work and unsure of what you are doing, you may want to first ask for permission from your system administrator or whoever handles the administration of your system. If you booted up your system and it went directly into X, this means that the system has been configured to do so automatically. If it didn't, you can configure it to load automatically if you like. To start the X Window System manually after you log in, type the following: >startx There are two primary ways to load X: either a shell script called startx (which is also known as x11 in some distributions) or the xinit program. Using startx will automate function calls to xinit, and thus is the preferred method to start X. In Lesson 14, "Shell Scripting Fundamentals," we will cover shell scripting in more depth. Now that you know how to start the X Window System, let's talk more about it and what you need to know about starting applications. After the X server starts itself, you will need to start some X applications as well. There is a default set available upon boot-up. A file called .xinitrc is located in your home directory. When Unix boots up, .xinitrc is automatically executed. Although this file is common, not all versions of Unix use it. Here are some examples of files used in other versions:
So what does an .xinitrc file look like? Here's an example: #!/bin/sh xrdb -load $HOME/.X11defaults xscreensaver -timeout 10 & xterm -geometry 80x30+10+10 & An .xinitrc file, when dissected line by line, appears as follows:
The server resource database is discussed later in this lesson.
Now that you understand the basics of the X Window System, the xinit program, startx, and the .xinitrc file, let's tie it all together so it makes sense and so you can learn how to make configuration changes to your Unix environment. This way, you can become more comfortable while working in your Unix environment. Tying It All TogetherThe xinit program is used to start the X Window System server. The first client program listed will be launched. This is launched from /etc/init. In cases in which a program is not listed, xinit will look for a file in the user's home directory. This file (shell script) is called .xinitrc. If this shell script does not exist, you can create one in your home directory that can be used. Let's look at this file again: #!/bin/sh xrdb -load $HOME/.X11defaults xscreensaver -timeout 10 & xterm -geometry 80x30+10+10 & The first line in the .xinitrc file is used to declare the shell in which the script is written. Whatever shell you ultimately decide to use will dictate the commands you use within it. What this means is that if you use the C shell to write your script, you should be sure to use commands that are known within the C shell syntax. In the first line of our example script, we see sh, which stands for the Bourne shell. sh is the standard Unix system command interpreter and will work for now if you use simple scripts. More complex scripting will require the use of a more complex shell, such as the C shell. sh executes commands that are either specified in a file or executed from the terminal where you sit. In the next line of the example, you will see a personal initialization file called $HOME/.X11defaults. .X11defaults is nothing more than a profile file; that's it. You can edit your $HOME/. profile file by hand. We will learn how to do this in Part III, "File System Utilities," where we will discuss editing files in Unix.
Your next step is to launch any applications you may want to use. When viewing the example .xinitrc file again, you can see that programs such as an xterm window and xscreensaver are both launched in the background. Think about what other programs you may want to start during the boot-up of your system. Helpful suggestions for what you may want to eventually add include a window manager and perhaps your e-mail client. No matter what you decide, the important thing to understand and learn here is how and where to make this change; once you know how to edit files, you can find things you want to launch and add them later. In our example, the controlling process is the xterm window. When you close something that is designated as a controlling process, doing so will close you out of your entire X Window System session. Let's look at another sample .xinitrc script: #! /bin/sh xrdb $HOME/.Xprofile xsetroot -solid gray & xclock -g 60x50-0+0 -bw 0 & xterm -g 60X24+0+0 & xterm -g 60x24+0-0 You can see that this script is similar to the last one, and that is good. You will start to remember things such as this, and that's all it takes to learn Unix! In this sample script, you can see the power of Unix starting to open up; you can basically script anything and have it run automatically. You can even have scripts that call up other scriptsthe flexibility is endless. To continue with our example and tie this all together, let's examine the last line of the script. The last line should be your controlling process, and when you have a controlling process, this is the one time that you do not add the ampersand. So what does this sample .xinitrc file do? With this file, xinit will start, and your .Xprofile file will be read. Once read, your environment will start to develop. In this example, the root window will be set to solid gray. A clock will be used. Two xterm sessions (one as a controlling process) and an xconsole window will be initialized.
|