Although you may be satisfied with the default colors that X
gives you, I am sure that eventually you will want to make some changes. In previous sections, I
talked about how you can change the color of X clients either from the
command line or by changing the appropriate resource. The only problem with that is you might not
like the colors that Linux offers.
You might ask, "Why doesn't the system just give me a list with every possible color?" Well, you
would need to have that list in a file somewhere. If you did, you would have a list that was more
than 20Mb because of the way Linux stores colors.
Each color is represented by one byte for each of the three colors: red, green, and blue
(referred to as the RGB scheme). Each byte can have one of 256 values that represent the intensity of each color. In other words, the value represents how much of each color is included in a shade. If all three colors have the value 255, the shade is pure white. If each color has the value 0, the shade is black.
The /usr/lib/X11/rgb.txt file contains names of colors and, often, variations in that name. This is usually the case when the name of the color actually consists of two words, for example, antique
white. In such a case, you would also find the color antique-white. Each entry contains the RGB
values and the name of the color. For example, the antique white entry would look like this:
250 235 215 antique-white
This means that the intensity of red in this color is 250/255 of full intensity, the intensity of
green is 235/255, and the intensity of blue is 215/255. What this really means is how much energy is
sent to each phosphor. For details on what phosphors are and what part they play in displaying an
image, see the section on monitors in the chapter on hardware.
If you specify the color as a resource (either from the command line
or a resource file), you specify the color as a hexadecimal
value. The key thing to note is that you must specify the value for each color, even if it is 0.
Because the hexadecimal values range from 0000 to FFFF, you have many more possible combinations of
colors. When you specify colors in this way, the hex string you use must be preceded by a pound-sign
If you don't want to specify all four hexadecimal
digits, you do not have to. However, all three colors need to be represented with the same number of
digits because the system would not be able to tell what value goes with which settings. If we look
at an example, this will be clearer.
Lets assume you want to set the intensity of red to F, the intensity of green to 4, and the
intensity of blue to 2. You might then have a resource specification that looked like this:
If we wanted the intensity of green to be 45 instead of 4, the resource specification might look
So what is it? Do we have red at F4, green at 5, and blue at 2? Or do we have red at F, green at
4, and blue at 52? The only way to keep things straight is if there are the same number of digits for each color.
Remember that not all video systems are created equal. You may not get the same color on your
system as someone else does, even if you use the exact same hex values.