Take the 2-minute tour ×
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.

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
1  
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
add comment

2 Answers

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 ...) –  jrtayloriv 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
1  
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 –  jrtayloriv Mar 21 '11 at 20:25
add comment

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
add comment

Your Answer

 
discard

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.