4

In the Iron Age it was possible to edit /etc/X11/rgb.txt and voila, the X server knew the new names of some new color.

Parentetically, imvho this was especially useful because the rgb.text database had (and still has) a shortage of dark colors, and had essentially no "numbered" dark colors.

Unfortunately, now the X server uses a builtin version of rgb.txt, and doesn't care of the text file.

Is it possible to change the RGB database of the X server at runtime?


E.g., when I needed a few different shades of dark red for the elements of a user interface I could append to rgb.txt the following lines

 63 31 31 OxBlood1 ... ... 31 0 0 OxBlood4 
2
  • wow! This is some retro stuff. I believe these lists are still kept around as module. Are you using some major Linux distro? Do you need the list, or what it is used for by the x server? Commented Dec 8, 2021 at 12:58
  • @MarcusMüller I have the list already... E.g., Debian has still /etc/X11/rgb.txt while Suse has moved the text file to /usr/share/X11/rgb.txt, possibly to underline the fact that the server doesn't read the color db from the filesystem., and X has a command line option to dump its internal color database. So no, thank you but I'm not interested in the list or the internal database, I'd like to be able to install a new color in a running X server Commented Dec 8, 2021 at 13:56

1 Answer 1

2

Maybe.

The X.org man page on Color Names says:

X supports the use of abstract color names, for example, "red", "blue". A value for this abstract name is obtained by searching one or more color name databases. Xlib first searches zero or more client-side databases; the number, location, and content of these databases is implementation dependent. If the name is not found, the color is looked up in the X server’s database.

On the client side, if the server is built with XCMS support, XLookupColor reads the colorspace definitions from Xcms.txt, which contains definitions that look like this:

XCMS_COLORDB_START 0.1 cms red CIEXYZ:0.3811/0.2073/0.0213 cms green CIEXYZ:0.3203/0.6805/0.1430 cms blue CIEXYZ:0.2483/0.1122/1.2417 XCMS_COLORDB_END 

Without XCMS (or with XCMS but no match on name), the client sends the request to the server, which initialized its color table by looping over a static table to pre-allocate the colors built from an upstream app. There is no code that triggers the reallocation of colors at run-time.

It's been this way for a while: X.org removed support for an external rgb.txt file on 2007-11-05, and documented it on 2009-02-12.

In contemporary code, the total set of options appear to be:

  1. If your build has XCMS support, then you can use a named colorspace definition to approximate the behavior of rgb.txt. This is the closest fit with the prior behavior.
  2. You could poke the process memory and replace an allocated color with the desired color, but Hic sunt dragones.
  3. You could build the server yourself, extending the table with your definition or perhaps reverting the commit that removed rgb.txt support.
  4. You could lobby upstream to include your colors and hope they incorporate your PR.
5
  • wrt option 4, I have no more a clear recollection of the events (time flies), but I tried to lobby when it happened Commented Jan 15, 2023 at 10:50
  • wrt option 3, if memory is helping, that's exactly what K.P. told me. Commented Jan 15, 2023 at 10:52
  • wrt option 2, no, thank you Commented Jan 15, 2023 at 10:53
  • wrt option 1, xdpyinfo reports that I have the XC-MISC extension, is that covering for XCMS support? Commented Jan 15, 2023 at 10:57
  • No, XC-MISC is protocol for querying resource ID on the X server. Xcms is a client side capability, so xdpyinfo won't tell you about it. I'd just grep the library to see if it's referenced: strings /usr/lib/libX11.so.6 | grep -i xcms. You can also just look for the file and edit it: find / -name Xcms.txt. Commented Jan 15, 2023 at 14:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.