summaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/parser.c b/src/parser.c
index a2de128..7cc59d1 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -233,7 +233,7 @@ found:
cfg->snap_distance = atoi(rest);
}
else if (!strcmp(key, "should_float")) {
- // should_float: <window>
+ // should_float: binary --arg,binary2 parameter --arg,binary3
if (should_floatn >= 256) {
fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno);
@@ -241,14 +241,46 @@ found:
}
char *win = strip(rest);
+
+ cfg->should_float[should_floatn] = malloc(256 * sizeof(char *));
- cfg->should_float[should_floatn] = malloc(strlen(win) + 1);
- if (!cfg->should_float[should_floatn]) {
- fprintf(stderr, "sxwmrc:%d: out of memory\n", lineno);
- break;
+ char *comma_ptr, *space_ptr;
+ char *comma = strtok_r(win, ",", &comma_ptr);
+
+ while (comma) {
+ if (should_floatn < 256) {
+ // if comma starts and ends with quotes, remove them
+ if (*comma == '"') {
+ comma++;
+ }
+ char *end = comma + strlen(comma) - 1;
+ if (*end == '"') {
+ *end = '\0';
+ }
+
+ printf("comma: %s\n", comma);
+ char *argv = strtok_r(comma, " ", &space_ptr);
+ int i = 0;
+
+
+ while (argv) {
+ printf("argv: %s\n", argv);
+ cfg->should_float[should_floatn][i] = strdup(argv);
+ argv = strtok_r(NULL, " ", &space_ptr);
+ i++;
+ }
+
+ should_floatn++;
+ cfg->should_float[should_floatn] = malloc(256 * sizeof(char *));
+
+ } else {
+ fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno);
+ break;
+ }
+ comma = strtok_r(NULL, ",", &comma_ptr);
}
- strcpy(cfg->should_float[should_floatn], win);
+
should_floatn++;
}
else if (!strcmp(key, "call") || !strcmp(key, "bind")) {
@@ -332,6 +364,15 @@ found:
}
}
+ // print should_float
+ for (int i = 0; i < should_floatn; i++) {
+ fprintf(stderr, "sxwmrc: should_float[%d]: ", i);
+ for (int j = 0; cfg->should_float[i][j]; j++) {
+ fprintf(stderr, "%s ", cfg->should_float[i][j]);
+ }
+ fprintf(stderr, "\n");
+ }
+
fclose(f);
remap_and_dedupe_binds(cfg);
return 0;