aboutsummaryrefslogblamecommitdiff
path: root/bin/xrq.awk
blob: 686cf6773fed448631bae82a71c72287d0e1bb8e (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                                              
                                                                








                                                                          






                                                       
# 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 >&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
            }
        }
    }

    # Exit successfully if we found at least one result
    exit(!found)
}