Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used xsetroot -solid "#xxxxxx" to set a background color. I like this color, but did not record the command and it's long gone from the bash shell history. How can I find out what the color was?

share|improve this question
I know how to do it from a program (painfully), but don't think there's a good way to get it from the shell. Short version is to use XGetImage() to grab a visible part of the root window, then XGetPixel() to read the color value out of it. – geekosaur Mar 20 '11 at 1:39
up vote 1 down vote accepted

I would just use the Color Picker tool from Gimp, which will let you click anywhere on the screen and will give you the RGB value for the color at that point.

share|improve this answer
That tool seems to be limited only to gimp's own image windows. Unless there's a secret trick to it? – DarenW Mar 20 '11 at 2:35
OTOH, gimp works great on image, and that image can be a screen capture of the desktop. Problem solved. (Duh, is obvious.) Still would be nice to have a way to retrieve exactly what was given to xsetroot. – DarenW Mar 20 '11 at 2:43
I'm sorry Daren -- I thought I remembered an option to select outside of Gimp with the Color Picker tool ... what I was thinking about is the picker that's in the color selection dialog (when you click to change the color for your brushes -- the dropper that's in the color selection dialog) -- that one will let you select from anywhere without having to take a screenshot. (I think I'll going to write a patch to make the color picker tool do that too though ...) – J. Taylor Mar 20 '11 at 5:22
Ah, I didn't think of using the color selection dialog (from clicking on the white/black overlapping squares); tried only the eyedropper in the toolbox. – DarenW Mar 21 '11 at 16:01
I asked the gimp developers why the Color Picker tool (i.e. the one in the Toolbox, rather than the picker in the color selection dialog) isn't able to grab off screen, and they explained that it's because you'd have to globally grab the mouse until the user selected a color, which is different from how all of the other tools act (i.e. none of the other tools can grab the mouse): bugzilla.gnome.org/show_bug.cgi?id=645282 – J. Taylor Mar 21 '11 at 20:25

Assuming it still is the color of the root window: run xcolorsel (part of the contributed X utility set; some distributions pack it separately), click the “Grab color” button, and click somewhere on your root window. The numbers you want are the ones below the color list box. Change the display format to “8 bit scalred rgb” to have something familiar.

share|improve this answer
It took a while to find it. Now I have xcolorsel, but it won't run. – DarenW Mar 20 '11 at 2:39

Use well known color names compilation https://en.wikipedia.org/wiki/X11_color_names:

$ apt-file search rgb.txt
x11-common: /etc/X11/rgb.txt

$ less /etc/X11/rgb.txt
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.