ret = read(readpipe[0], converted + read_bytes, conv_size - read_bytes);
if (ret == -1) {
warn("Cannot read from pipe");
+ FREE(converted);
return NULL;
}
read_bytes += ret;
continue;
if (strcasecmp(key, "set") == 0) {
- if (value[0] != '$')
- die("Malformed variable assignment, name has to start with $\n");
+ if (value[0] != '$') {
+ ELOG("Malformed variable assignment, name has to start with $\n");
+ continue;
+ }
/* get key/value for this variable */
char *v_key = value, *v_value;
- if ((v_value = strstr(value, " ")) == NULL)
- die("Malformed variable assignment, need a value\n");
+ if (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
+ ELOG("Malformed variable assignment, need a value\n");
+ continue;
+ }
+
+ if (!(v_value = strstr(value, " ")))
+ v_value = strstr(value, "\t");
*(v_value++) = '\0';
int extra = (strlen(current->value) - strlen(current->key));
char *next;
for (next = bufcopy;
- (next = strcasestr(bufcopy + (next - bufcopy), current->key)) != NULL;
+ next < (bufcopy + stbuf.st_size) &&
+ (next = strcasestr(next, current->key)) != NULL;
next += strlen(current->key)) {
*next = '_';
extra_bytes += extra;
%token TOK_MARK "mark"
%token TOK_CLASS "class"
+%token TOK_INSTANCE "instance"
%token TOK_ID "id"
%token TOK_CON_ID "con_id"
%token TOK_TITLE "title"
for_window:
TOK_FOR_WINDOW match command
{
+ if (match_is_empty(¤t_match)) {
+ ELOG("Match is empty, ignoring this for_window statement\n");
+ break;
+ }
printf("\t should execute command %s for the criteria mentioned above\n", $3);
Assignment *assignment = scalloc(sizeof(Assignment));
assignment->type = A_COMMAND;
printf("criteria: class = %s\n", $3);
current_match.class = $3;
}
+ | TOK_INSTANCE '=' STR
+ {
+ printf("criteria: instance = %s\n", $3);
+ current_match.instance = $3;
+ }
| TOK_CON_ID '=' STR
{
printf("criteria: id = %s\n", $3);
}
DLOG("Should assign workspace %s to output %s\n", ws_name, $4);
- struct Workspace_Assignment *assignment = scalloc(sizeof(struct Workspace_Assignment));
- assignment->name = ws_name;
- assignment->output = $4;
- TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
+ /* Check for earlier assignments of the same workspace so that we
+ * don’t have assignments of a single workspace to different
+ * outputs */
+ struct Workspace_Assignment *assignment;
+ bool duplicate = false;
+ TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
+ if (strcasecmp(assignment->name, ws_name) == 0) {
+ ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
+ ws_name);
+ assignment->output = $4;
+ duplicate = true;
+ }
+ }
+ if (!duplicate) {
+ assignment = scalloc(sizeof(struct Workspace_Assignment));
+ assignment->name = ws_name;
+ assignment->output = $4;
+ TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
+ }
}
}
| TOKWORKSPACE NUMBER workspace_name
char *hex;
if (asprintf(&hex, "#%s", $2) == -1)
die("asprintf()");
+ free($2);
$$ = get_colorpixel(hex);
free(hex);
}