Fixes #562.
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\" Date: 10/30/2016
+.\" Date: 11/04/2016
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.2
.\" Language: English
.\"
-.TH "BSPWM" "1" "10/30/2016" "Bspwm 0\&.9\&.2" "Bspwm Manual"
+.TH "BSPWM" "1" "11/04/2016" "Bspwm 0\&.9\&.2" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.PP
\fB\-D\fR, \fB\-\-desktops\fR [\fIDESKTOP_SEL\fR]
.RS 4
-List the IDs of the matching desktops\&.
+List the IDs (or names) of the matching desktops\&.
.RE
.PP
\fB\-M\fR, \fB\-\-monitors\fR [\fIMONITOR_SEL\fR]
.RS 4
-List the IDs of the matching monitors\&.
+List the IDs (or names) of the matching monitors\&.
.RE
.PP
\fB\-T\fR, \fB\-\-tree\fR
and
\fI\-N\fR\&.
.RE
+.PP
+\fB\-\-names\fR
+.RS 4
+Print names instead of IDs\&.
+.RE
.RE
.SS "Wm"
.sp
List the IDs of the matching nodes.
*-D*, *--desktops* ['DESKTOP_SEL']::
- List the IDs of the matching desktops.
+ List the IDs (or names) of the matching desktops.
*-M*, *--monitors* ['MONITOR_SEL']::
- List the IDs of the matching monitors.
+ List the IDs (or names) of the matching monitors.
*-T*, *--tree*::
Print a JSON representation of the matching item.
*-n*, *--node* ['NODE_SEL']::
Constrain matches to the selected monitor, desktop or node. The descriptor can be omitted for '-M', '-D' and '-N'.
+*--names*::
+ Print names instead of IDs.
+
Wm
~~
desktop_select_t *desktop_sel = NULL;
node_select_t *node_sel = NULL;
domain_t dom = DOMAIN_TREE;
+ bool print_ids = true;
uint8_t d = 0;
if (num < 1) {
goto end;
}
}
+ } else if (streq("--names", *args)) {
+ print_ids = false;
} else {
fail(rsp, "query: Unknown option: '%s'.\n", *args);
goto end;
fail(rsp, "");
}
} else if (dom == DOMAIN_DESKTOP) {
- if (query_desktop_ids(&ref, &trg, desktop_sel, rsp) < 1) {
+ if (query_desktop_ids(&ref, &trg, desktop_sel, print_ids ? fprint_desktop_id : fprint_desktop_name, rsp) < 1) {
fail(rsp, "");
}
} else if (dom == DOMAIN_MONITOR) {
- if (query_monitor_ids(&ref, &trg, monitor_sel, rsp) < 1) {
+ if (query_monitor_ids(&ref, &trg, monitor_sel, print_ids ? fprint_monitor_id : fprint_monitor_name, rsp) < 1) {
fail(rsp, "");
}
} else {
return count;
}
-int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, FILE *rsp)
+int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, desktop_printer_t printer, FILE *rsp)
{
int count = 0;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
(sel != NULL && !desktop_matches(&loc, ref, *sel))) {
continue;
}
- fprintf(rsp, "0x%08X\n", d->id);
+ printer(d, rsp);
count++;
}
}
return count;
}
-int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *sel, FILE *rsp)
+int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *sel, monitor_printer_t printer, FILE *rsp)
{
int count = 0;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
(sel != NULL && !monitor_matches(&loc, ref, *sel))) {
continue;
}
- fprintf(rsp, "0x%08X\n", m->id);
+ printer(m, rsp);
count++;
}
return count;
}
+void fprint_monitor_id(monitor_t *m, FILE *rsp)
+{
+ fprintf(rsp, "0x%08X\n", m->id);
+}
+
+void fprint_monitor_name(monitor_t *m, FILE *rsp)
+{
+ fprintf(rsp, "%s\n", m->name);
+}
+
+void fprint_desktop_id(desktop_t *d, FILE *rsp)
+{
+ fprintf(rsp, "0x%08X\n", d->id);
+}
+
+void fprint_desktop_name(desktop_t *d, FILE *rsp)
+{
+ fprintf(rsp, "%s\n", d->name);
+}
+
void print_modifier_mask(uint16_t m, FILE *rsp)
{
switch (m) {
SELECTOR_BAD_DESCRIPTOR
};
+typedef void (*monitor_printer_t)(monitor_t *m, FILE *rsp);
+typedef void (*desktop_printer_t)(desktop_t *m, FILE *rsp);
+
void query_tree(FILE *rsp);
void query_monitor(monitor_t *m, FILE *rsp);
void query_desktop(desktop_t *d, FILE *rsp);
void query_stack(FILE *rsp);
int query_node_ids(coordinates_t *ref, coordinates_t *trg, node_select_t *sel, FILE *rsp);
int query_node_ids_in(node_t *n, desktop_t *d, monitor_t *m, coordinates_t *ref, coordinates_t *trg, node_select_t *sel, FILE *rsp);
-int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, FILE *rsp);
-int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *sel, FILE *rsp);
+int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, desktop_printer_t printer, FILE *rsp);
+int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *sel, monitor_printer_t printer, FILE *rsp);
+void fprint_monitor_id(monitor_t *m, FILE *rsp);
+void fprint_monitor_name(monitor_t *m, FILE *rsp);
+void fprint_desktop_id(desktop_t *d, FILE *rsp);
+void fprint_desktop_name(desktop_t *d, FILE *rsp);
void print_modifier_mask(uint16_t m, FILE *rsp);
void print_pointer_action(pointer_action_t a, FILE *rsp);
node_select_t make_node_select(void);