Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents
Up to --> Linux Tutorial

· The X Windowing System
· Configuring the X-Windows Server
· The Basics of X
· Resources
· Colors
· Displaying Clients
· Fonts
· The Window Manager
· Remote Access

Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
Copyright Info
Terms of Use
Privacy Info
Masthead / Impressum
Your Account

Private Messages

News Archive
Submit News
User Articles
Web Links


The Web

Who's Online
There are currently, 114 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

Linux Tutorial - The X Windowing System - Colors
  Resources ---- Displaying Clients   


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:

*background: #F42

If we wanted the intensity of green to be 45 instead of 4, the resource specification might look like this:

*background: #F452

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.

 Previous Page
  Back to Top
Table of Contents
Next Page 
Displaying Clients


Test Your Knowledge

User Comments:

You can only add comments if you are logged in.

Copyright 2002-2009 by James Mohr. Licensed under modified GNU Free Documentation License (Portions of this material originally published by Prentice Hall, Pearson Education, Inc). See here for details. All rights reserved.
Show your Support for the Linux Tutorial

Purchase one of the products from our new online shop. For each product you purchase, the Linux Tutorial gets a portion of the proceeds to help keep us going.



Security Code
Security Code
Type Security Code

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!

Amazon Wish List

Did You Know?
You can get all the latest Site and Linux news by checking out our news page.


Tell a Friend About Us

Bookmark and Share

Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.08 Seconds