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?
Asked
Active
Viewed 2,026 times
2
mrflash818
- 305
- 3
- 11
gmarmstrong
- 1,183
- 1
- 15
- 35
-
3You could just grep from what you want, for example: `xrdb -query | grep URxvt.internalBorder` – Andy Dalton May 04 '18 at 15:13
-
1And 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 Answers
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 -queryoutputs the current~/.Xresourcespropertiesgrep "foo.bar"gets the line on which a specific property is definedcut -f 2gets the second "field", excluding the first property
gmarmstrong
- 1,183
- 1
- 15
- 35