2

I would like to query a single value from ~/.Xresources. xrdb -query gives me the whole configuration, but I would specifically like to echo the value of an individual property (e.g., URxvt.internalBorder or *color14). How can I do this?

mrflash818
  • 305
  • 3
  • 11
gmarmstrong
  • 1,183
  • 1
  • 15
  • 35
  • 3
    You could just grep from what you want, for example: `xrdb -query | grep URxvt.internalBorder` – Andy Dalton May 04 '18 at 15:13
  • 1
    And if the solution with `grep` (IMHO the simplest one) is not acceptable: It's possible to do this using the X API, but you'll have to write your own program for it, e.g. in C. – dirkt May 05 '18 at 05:43

1 Answers1

1

Here's a solution using grep and cut to parse the output of xrdb -query:

xrdb -query | grep "URxvt.internalBorder" | cut -f 2

returns 30. Another example:

xrdb -query | grep "*color14" | cut -f 2

returns #d65d0e.

Translation:

  • xrdb -query outputs the current ~/.Xresources properties
  • grep "foo.bar" gets the line on which a specific property is defined
  • cut -f 2 gets the second "field", excluding the first property
gmarmstrong
  • 1,183
  • 1
  • 15
  • 35