.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\" Date: 09/08/2017
+.\" Date: 09/29/2017
.\" Manual: Bspwm Manual
-.\" Source: Bspwm 0.9.3-26-g412da35
+.\" Source: Bspwm 0.9.3-30-gd953f6f
.\" Language: English
.\"
-.TH "BSPWM" "1" "09/08/2017" "Bspwm 0\&.9\&.3\-26\-g412da35" "Bspwm Manual"
+.TH "BSPWM" "1" "09/29/2017" "Bspwm 0\&.9\&.3\-30\-gd953f6f" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.PP
\fIexternal_rules_command\fR
.RS 4
-External command used to retrieve rule consequences\&. The command will receive the following arguments: window ID, class and instance names, monitor, desktop and node selectors\&. The output of that command must have the following format:
+External command used to retrieve rule consequences\&. The command will receive the following arguments: window ID, class name, instance name, and intermediate consequences\&. The output of that command must have the following format:
\fBkey1=value1 key2=value2 \&...\fR
(the valid key/value pairs are given in the description of the
\fIrule\fR
Prefix prepended to each of the status lines.
'external_rules_command'::
- External command used to retrieve rule consequences. The command will receive the following arguments: window ID, class and instance names, monitor, desktop and node selectors. The output of that command must have the following format: *key1=value1 key2=value2 ...* (the valid key/value pairs are given in the description of the 'rule' command).
+ External command used to retrieve rule consequences. The command will receive the following arguments: window ID, class name, instance name, and intermediate consequences. The output of that command must have the following format: *key1=value1 key2=value2 ...* (the valid key/value pairs are given in the description of the 'rule' command).
'initial_polarity'::
On which child should a new window be attached when adding a window on a single window tree in automatic mode. Accept the following values: *first_child*, *second_child*.
return fifo_path;
}
+int asprintf(char **buf, const char *fmt, ...)
+{
+ int size = 0;
+ va_list args;
+ va_start(args, fmt);
+ size = vasprintf(buf, fmt, args);
+ va_end(args);
+ return size;
+}
+
+int vasprintf(char **buf, const char *fmt, va_list args)
+{
+ int size = 0;
+
+ va_list tmp;
+ va_copy(tmp, args);
+ size = vsnprintf(NULL, size, fmt, tmp);
+ va_end(tmp);
+
+ if (size < 0) {
+ return -1;
+ }
+
+ *buf = malloc(size + 1);
+
+ if (*buf == NULL) {
+ return -1;
+ }
+
+ size = vsprintf(*buf, fmt, args);
+ return size;
+}
+
/* Adapted from i3wm */
uint32_t get_color_pixel(const char *color)
{
void err(char *fmt, ...);
char *read_string(const char *file_path, size_t *tlen);
char *copy_string(char *str, size_t len);
-char *mktempfifo(const char *template) ;
+char *mktempfifo(const char *template);
+int asprintf(char **buf, const char *fmt, ...);
+int vasprintf(char **buf, const char *fmt, va_list args);
uint32_t get_color_pixel(const char *color);
bool is_hex_color(const char *color);
}
}
+void print_rule_consequence(char **buf, rule_consequence_t *csq)
+{
+ char *rect_buf = NULL;
+ print_rectangle(&rect_buf, csq->rect);
+ if (rect_buf == NULL) {
+ rect_buf = malloc(1);
+ *rect_buf = '\0';
+ }
+ asprintf(buf, "monitor=%s desktop=%s node=%s state=%s layer=%s split_dir=%s split_ratio=%lf hidden=%s sticky=%s private=%s locked=%s center=%s follow=%s manage=%s focus=%s border=%s rectangle=%s",
+ csq->monitor_desc, csq->desktop_desc, csq->node_desc,
+ csq->state == NULL ? "" : STATE_STR(*csq->state),
+ csq->layer == NULL ? "" : LAYER_STR(*csq->layer),
+ csq->split_dir, csq->split_ratio,
+ ON_OFF_STR(csq->hidden), ON_OFF_STR(csq->sticky), ON_OFF_STR(csq->private),
+ ON_OFF_STR(csq->locked), ON_OFF_STR(csq->center), ON_OFF_STR(csq->follow),
+ ON_OFF_STR(csq->manage), ON_OFF_STR(csq->focus), ON_OFF_STR(csq->border), rect_buf);
+ free(rect_buf);
+}
+
+void print_rectangle(char **buf, xcb_rectangle_t *rect)
+{
+ if (rect != NULL) {
+ asprintf(buf, "%hux%hu+%hi+%hi", rect->width, rect->height, rect->x, rect->y);
+ }
+}
+
node_select_t make_node_select(void)
{
node_select_t sel = {
void print_modifier_mask(uint16_t m, FILE *rsp);
void print_button_index(int8_t b, FILE *rsp);
void print_pointer_action(pointer_action_t a, FILE *rsp);
+void print_rule_consequence(char **buf, rule_consequence_t *csq);
+void print_rectangle(char **buf, xcb_rectangle_t *rect);
node_select_t make_node_select(void);
desktop_select_t make_desktop_select(void);
monitor_select_t make_monitor_select(void);
#include "bspwm.h"
#include "ewmh.h"
#include "window.h"
+#include "query.h"
#include "parse.h"
#include "settings.h"
#include "rule.h"
dup2(fds[1], 1);
close(fds[0]);
char wid[SMALEN];
+ char *csq_buf;
+ print_rule_consequence(&csq_buf, csq);
snprintf(wid, sizeof(wid), "%i", win);
setsid();
- execl(external_rules_command, external_rules_command, wid, csq->class_name, csq->instance_name, csq->monitor_desc, csq->desktop_desc, csq->node_desc, NULL);
+ execl(external_rules_command, external_rules_command, wid, csq->class_name, csq->instance_name, csq_buf, NULL);
+ free(csq_buf);
err("Couldn't spawn rule command.\n");
} else if (pid > 0) {
close(fds[1]);