]> git.lizzy.rs Git - bspwm.git/commitdiff
Allow multiple constraints for the *query* domain
authorBastien Dejean <nihilhill@gmail.com>
Thu, 14 Apr 2016 21:15:58 +0000 (23:15 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Thu, 14 Apr 2016 21:15:58 +0000 (23:15 +0200)
Example:
    bspc query -N -d '^3' -n .window

The above command will list the IDs of the windows of the third desktop.

doc/bspwm.1
doc/bspwm.1.asciidoc
messages.c

index c894fde53edf3c11ee8ab992a9d3fae35596e291..eaa801c65febe42aee540ec380cfe28627d91077 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      Date: 04/10/2016
+.\"      Date: 04/14/2016
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.1-16-gc6c52e2
+.\"    Source: Bspwm 0.9.1-26-g789cb8a
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "04/10/2016" "Bspwm 0\&.9\&.1\-16\-gc6c52e2" "Bspwm Manual"
+.TH "BSPWM" "1" "04/14/2016" "Bspwm 0\&.9\&.1\-26\-g789cb8a" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -806,7 +806,7 @@ Print a JSON representation of the matching item\&.
 \fBOptions\fR
 .RS 4
 .PP
-[\fB\-m\fR,\fB\-\-monitor\fR [\fIMONITOR_SEL\fR]] | [\fB\-d\fR,\fB\-\-desktop\fR [\fIDESKTOP_SEL\fR]] | [\fB\-n\fR, \fB\-\-node\fR [\fINODE_SEL\fR]]
+\fB\-m\fR,\fB\-\-monitor\fR [\fIMONITOR_SEL\fR], \fB\-d\fR,\fB\-\-desktop\fR [\fIDESKTOP_SEL\fR], \fB\-n\fR, \fB\-\-node\fR [\fINODE_SEL\fR]
 .RS 4
 Constrain matches to the selected monitor, desktop or node\&. The descriptor can be omitted for
 \fI\-M\fR,
index 855248528a10a1a3b6bf6b6f67adecd50363cd95..41701dc104d5b97abb1a5159bdfeb2a6abbb1b6d 100644 (file)
@@ -476,7 +476,9 @@ Commands
 Options
 ^^^^^^^
 
-[*-m*,*--monitor* ['MONITOR_SEL']] | [*-d*,*--desktop* ['DESKTOP_SEL']] | [*-n*, *--node* ['NODE_SEL']]::
+*-m*,*--monitor* ['MONITOR_SEL']::
+*-d*,*--desktop* ['DESKTOP_SEL']::
+*-n*, *--node* ['NODE_SEL']::
        Constrain matches to the selected monitor, desktop or node. The descriptor can be omitted for '-M', '-D' and '-N'.
 
 Wm
index 5059f839bb8f753937e536db6b3e19be7c28287b..cfded87b4dc02bcf1ec624b3aa3d80a4d1b433ef 100644 (file)
@@ -883,17 +883,21 @@ void cmd_query(char **args, int num, FILE *rsp)
        desktop_select_t *desktop_sel = NULL;
        node_select_t *node_sel = NULL;
        domain_t dom = DOMAIN_TREE;
-       int d = 0, t = 0;
+
+       if (num < 1) {
+               fail(rsp, "query: Not enough arguments.\n");
+               return;
+       }
 
        while (num > 0) {
                if (streq("-T", *args) || streq("--tree", *args)) {
-                       dom = DOMAIN_TREE, d++;
+                       dom = DOMAIN_TREE;
                } else if (streq("-M", *args) || streq("--monitors", *args)) {
-                       dom = DOMAIN_MONITOR, d++;
+                       dom = DOMAIN_MONITOR;
                } else if (streq("-D", *args) || streq("--desktops", *args)) {
-                       dom = DOMAIN_DESKTOP, d++;
+                       dom = DOMAIN_DESKTOP;
                } else if (streq("-N", *args) || streq("--nodes", *args)) {
-                       dom = DOMAIN_NODE, d++;
+                       dom = DOMAIN_NODE;
                } else if (streq("-m", *args) || streq("--monitor", *args)) {
                        if (num > 1 && *(args + 1)[0] != OPT_CHR) {
                                num--, args++;
@@ -916,7 +920,6 @@ void cmd_query(char **args, int num, FILE *rsp)
                        } else {
                                trg.monitor = ref.monitor;
                        }
-                       t++;
                } else if (streq("-d", *args) || streq("--desktop", *args)) {
                        if (num > 1 && *(args + 1)[0] != OPT_CHR) {
                                num--, args++;
@@ -940,7 +943,6 @@ void cmd_query(char **args, int num, FILE *rsp)
                                trg.monitor = ref.monitor;
                                trg.desktop = ref.desktop;
                        }
-                       t++;
                } else if (streq("-n", *args) || streq("--node", *args)) {
                        if (num > 1 && *(args + 1)[0] != OPT_CHR) {
                                num--, args++;
@@ -967,7 +969,6 @@ void cmd_query(char **args, int num, FILE *rsp)
                                        goto end;
                                }
                        }
-                       t++;
                } else {
                        fail(rsp, "query: Unknown option: '%s'.\n", *args);
                        goto end;
@@ -975,8 +976,8 @@ void cmd_query(char **args, int num, FILE *rsp)
                num--, args++;
        }
 
-       if (d != 1 || t > 1) {
-               fail(rsp, "query: Exactly one domain and at most one constraint must be specified.\n");
+       if (dom == DOMAIN_TREE && trg.monitor == NULL) {
+               fail(rsp, "query -T: No constraints given.\n");
                goto end;
        }
 
@@ -997,11 +998,8 @@ void cmd_query(char **args, int num, FILE *rsp)
                        query_node(trg.node, rsp);
                } else if (trg.desktop != NULL) {
                        query_desktop(trg.desktop, rsp);
-               } else  if (trg.monitor != NULL) {
+               } else  {
                        query_monitor(trg.monitor, rsp);
-               } else {
-                       fail(rsp, "");
-                       goto end;
                }
                fprintf(rsp, "\n");
        }