aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-11 13:11:47 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-11 13:12:14 +1300
commitdd4392ef10ccd7f0722a7e865a52f1fb5ae06798 (patch)
tree9afcbe3ab2b27e4257094c3443d34a2cda84329c
parentChange some return codes for dir marking funcs (diff)
downloaddotfiles-dd4392ef10ccd7f0722a7e865a52f1fb5ae06798.tar.gz
dotfiles-dd4392ef10ccd7f0722a7e865a52f1fb5ae06798.zip
Add xrq(1df)
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rw-r--r--README.markdown2
-rwxr-xr-xbin/xrq.awk28
-rw-r--r--man/man1/xrq.1df16
5 files changed, 48 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index a9f181be..8250c055 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ bin/su2d
bin/tot
bin/unf
bin/uts
+bin/xrq
games/acq
games/aesth
games/chkl
diff --git a/Makefile b/Makefile
index 06d5adf3..e48ab590 100644
--- a/Makefile
+++ b/Makefile
@@ -92,6 +92,7 @@ BINS = bin/brnl \
bin/tot \
bin/unf \
bin/uts \
+ bin/xrq
GAMES = games/acq \
games/aesth \
diff --git a/README.markdown b/README.markdown
index b906c3f0..bb317a30 100644
--- a/README.markdown
+++ b/README.markdown
@@ -511,6 +511,8 @@ Installed by the `install-bin` target:
* `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`.
* `vex(1df)` runs a command and prints `true` or `false` explicitly to
`stdout` based on the exit value.
+* `xrq(1df)` gets the values of specific resources out of `xrdb -query`
+ output.
There's some silly stuff in `install-games`:
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)
+}
diff --git a/man/man1/xrq.1df b/man/man1/xrq.1df
new file mode 100644
index 00000000..245ac66f
--- /dev/null
+++ b/man/man1/xrq.1df
@@ -0,0 +1,16 @@
+.TH XRQ 1df "August 2016" "Manual page for xrq"
+.SH NAME
+.B xrq
+\- view the given URL in an appropriate program, falling back on $BROWSER
+.SH SYNOPSIS
+.B xrq
+Xft.hintstyle
+.br
+.B xrq
+URxvt.color0 URxvt.color9
+.SH DESCRIPTION
+.B xrq
+runs xrdb(1) with the -query option and filters for the values of the named
+keys. It exits successfully if at least one of the named keys was found.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>