From dd4392ef10ccd7f0722a7e865a52f1fb5ae06798 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 13:11:47 +1300 Subject: Add xrq(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 2 ++ bin/xrq.awk | 28 ++++++++++++++++++++++++++++ man/man1/xrq.1df | 16 ++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100755 bin/xrq.awk create mode 100644 man/man1/xrq.1df 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 -- cgit v1.2.3