aboutsummaryrefslogtreecommitdiff
path: root/bin/xrq.awk
diff options
context:
space:
mode:
Diffstat (limited to 'bin/xrq.awk')
-rw-r--r--bin/xrq.awk30
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/xrq.awk b/bin/xrq.awk
new file mode 100644
index 00000000..ffd5f124
--- /dev/null
+++ b/bin/xrq.awk
@@ -0,0 +1,30 @@
+# Run xrdb(1) to query specific resources from it
+# I thought xrdb -query would do this, but it doesn't seem to, maybe I'm doing
+# it wrong
+BEGIN {
+
+ # Separator is a colon followed by a tab
+ FS = ":\t"
+
+ # Check we have at least one resource name
+ if (ARGC < 2) {
+ stderr = "cat >&2"
+ print "xrq: Need at least one resource name" | stderr
+ close(stderr)
+ exit(2)
+ }
+
+ # Run `xrdb -query` and search for instances of the requested resource
+ xrdb = "xrdb -query"
+ found = 0
+ while (xrdb | getline)
+ for (i in ARGV)
+ if ($1 == ARGV[i]) {
+ found = 1
+ print $2
+ }
+ close(xrdb)
+
+ # Exit successfully if we found at least one result
+ exit(!found)
+}