summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/defs.h2
-rw-r--r--src/parser.c53
-rw-r--r--src/sxwm.c11
4 files changed, 58 insertions, 10 deletions
diff --git a/README.md b/README.md
index 60811a1..bd00cd1 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ The file uses a `key : value` format. Lines starting with `#` are ignored.
| `resize_master_amount` | Integer | `1` | Percent to increase/decrease master width. |
| `snap_distance` | Integer | `5` | Distance (px) before a floating window snaps to edge. |
| `motion_throttle` | Integer | `60` | Target FPS for mouse drag actions. |
-| `should_float` | String | `st` | Always-float rule (can list multiple). |
+| `should_float` | String | `"st"` | Always-float rule. Multiple entries should be comma-seperated. Optionally, entries can be enclosed in quotes.|
---
diff --git a/src/defs.h b/src/defs.h
index 6861262..d90ab61 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -87,7 +87,7 @@ typedef struct {
int snap_distance;
int bindsn;
Binding binds[256];
- char *should_float[256];
+ char **should_float[256];
} Config;
typedef struct {
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;
diff --git a/src/sxwm.c b/src/sxwm.c
index e7161d9..a40d69c 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -591,8 +591,15 @@ void hdl_keypress(XEvent *xev)
switch (b->type) {
case TYPE_CMD:
spawn(b->action.cmd);
- for (int j = 0; j < 256; j++) {
- if (user_config.should_float[j] && !strcmp(user_config.should_float[j], b->action.cmd[0])) {
+ for (int j = 0; j < 256; j++) {
+ Bool valid = False;
+ for (int k = 0; user_config.should_float[j] && user_config.should_float[j][k] && b->action.cmd[k]; k++) {
+ if (!strcmp(b->action.cmd[k], user_config.should_float[j][k])) {
+ valid = True;
+ break;
+ }
+ }
+ if (valid) {
next_should_float = True;
break;
}