diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-11 13:11:47 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-11 13:12:14 +1300 |
commit | dd4392ef10ccd7f0722a7e865a52f1fb5ae06798 (patch) | |
tree | 9afcbe3ab2b27e4257094c3443d34a2cda84329c /bin/xrq.awk | |
parent | Change some return codes for dir marking funcs (diff) | |
download | dotfiles-dd4392ef10ccd7f0722a7e865a52f1fb5ae06798.tar.gz dotfiles-dd4392ef10ccd7f0722a7e865a52f1fb5ae06798.zip |
Add xrq(1df)
Diffstat (limited to 'bin/xrq.awk')
-rwxr-xr-x | bin/xrq.awk | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/xrq.awk b/bin/xrq.awk new file mode 100755 index 00000000..c29bfb9d --- /dev/null +++ b/bin/xrq.awk @@ -0,0 +1,28 @@ +# 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) { + print "xrq: Need at least one resource name" | "cat 1>&2" + exit(2) + } + + # Run `xrdb -query` and search for instances of the requested resource + while ("xrdb -query" | getline) { + for (i in ARGV) { + if ($1 == ARGV[i]) { + found = 1 + print $2 + continue + } + } + } + + # Exit successfully if we found at least one result + exit(!found) +} |