summaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/src/parser.c b/src/parser.c
index 7cc59d1..eb6ba21 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -33,14 +33,6 @@ static const struct {
static void remap_and_dedupe_binds(Config *cfg)
{
for (int i = 0; i < cfg->bindsn; i++) {
- Binding *b = &cfg->binds[i];
- if (b->mods & (Mod1Mask | Mod4Mask)) {
- unsigned others = b->mods & ~(Mod1Mask | Mod4Mask);
- b->mods = others | cfg->modkey;
- }
- }
-
- for (int i = 0; i < cfg->bindsn; i++) {
for (int j = i + 1; j < cfg->bindsn; j++) {
if (cfg->binds[i].mods == cfg->binds[j].mods && cfg->binds[i].keysym == cfg->binds[j].keysym) {
memmove(&cfg->binds[j], &cfg->binds[j + 1], sizeof(Binding) * (cfg->bindsn - j - 1));
@@ -143,22 +135,22 @@ int parser(Config *cfg)
// check $XDG_CONFIG_HOME/sxwmrc, then $XDG_CONFIG_HOME/sxwm/sxwmrc, then $HOME/.config/sxwmrc
const char *xdg_config_home = getenv("XDG_CONFIG_HOME");
- if (xdg_config_home) {
- snprintf(path, sizeof path, "%s/sxwmrc", xdg_config_home);
- if (access(path, R_OK) == 0) {
- goto found;
- }
+ if (xdg_config_home) {
+ snprintf(path, sizeof path, "%s/sxwmrc", xdg_config_home);
+ if (access(path, R_OK) == 0) {
+ goto found;
+ }
- snprintf(path, sizeof path, "%s/sxwm/sxwmrc", xdg_config_home);
- if (access(path, R_OK) == 0) {
- goto found;
- }
- }
+ snprintf(path, sizeof path, "%s/sxwm/sxwmrc", xdg_config_home);
+ if (access(path, R_OK) == 0) {
+ goto found;
+ }
+ }
- snprintf(path, sizeof path, "%s/.config/sxwmrc", home);
- if (access(path, R_OK) == 0) {
- goto found;
- }
+ snprintf(path, sizeof path, "%s/.config/sxwmrc", home);
+ if (access(path, R_OK) == 0) {
+ goto found;
+ }
snprintf(path, sizeof path, "/usr/local/share/sxwmrc");
if (access(path, R_OK) == 0) {
@@ -166,11 +158,11 @@ int parser(Config *cfg)
}
found:
- FILE *f = fopen(path, "r");
- if (!f) {
- fprintf(stderr, "sxwmrc: cannot open %s\n", path);
- return -1;
- }
+ FILE *f = fopen(path, "r");
+ if (!f) {
+ fprintf(stderr, "sxwmrc: cannot open %s\n", path);
+ return -1;
+ }
char line[512];
int lineno = 0;
@@ -221,7 +213,10 @@ found:
cfg->border_swap_col = parse_col(rest);
}
else if (!strcmp(key, "master_width")) {
- cfg->master_width = atoi(rest) / 100.0f;
+ float mf = atoi(rest) / 100.0f;
+ for (int i = 0; i < MAX_MONITORS; i++) {
+ cfg->master_width[i] = mf;
+ }
}
else if (!strcmp(key, "motion_throttle")) {
cfg->motion_throttle = atoi(rest);
@@ -234,14 +229,14 @@ found:
}
else if (!strcmp(key, "should_float")) {
// should_float: binary --arg,binary2 parameter --arg,binary3
-
+
if (should_floatn >= 256) {
fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno);
continue;
}
char *win = strip(rest);
-
+
cfg->should_float[should_floatn] = malloc(256 * sizeof(char *));
char *comma_ptr, *space_ptr;
@@ -262,7 +257,6 @@ found:
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);
@@ -272,15 +266,14 @@ found:
should_floatn++;
cfg->should_float[should_floatn] = malloc(256 * sizeof(char *));
-
- } else {
+ }
+ else {
fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno);
break;
}
comma = strtok_r(NULL, ",", &comma_ptr);
}
-
should_floatn++;
}
else if (!strcmp(key, "call") || !strcmp(key, "bind")) {