* config.c: Parses the configuration (received from i3).
*
*/
+#include "common.h"
+
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
-#include "common.h"
-
static char *cur_key;
static bool parsing_bindings;
+static bool parsing_tray_outputs;
/*
* Parse a key.
FREE(cur_key);
sasprintf(&(cur_key), "%.*s", keyLen, keyVal);
- if (strcmp(cur_key, "bindings") == 0)
+ if (strcmp(cur_key, "bindings") == 0) {
parsing_bindings = true;
+ }
+
+ if (strcmp(cur_key, "tray_outputs") == 0) {
+ parsing_tray_outputs = true;
+ }
return 1;
}
static int config_end_array_cb(void *params_) {
parsing_bindings = false;
+ parsing_tray_outputs = false;
return 1;
}
return 0;
}
+ if (parsing_tray_outputs) {
+ DLOG("Adding tray_output = %.*s to the list.\n", len, val);
+ tray_output_t *tray_output = scalloc(1, sizeof(tray_output_t));
+ sasprintf(&(tray_output->output), "%.*s", len, val);
+ TAILQ_INSERT_TAIL(&(config.tray_outputs), tray_output, tray_outputs);
+ return 1;
+ }
+
if (!strcmp(cur_key, "mode")) {
DLOG("mode = %.*s, len = %d\n", len, val, len);
config.hide_on_modifier = (len == 4 && !strncmp((const char *)val, "dock", strlen("dock")) ? M_DOCK
if (!strcmp(cur_key, "modifier")) {
DLOG("modifier = %.*s\n", len, val);
+ if (len == 4 && !strncmp((const char *)val, "none", strlen("none"))) {
+ config.modifier = XCB_NONE;
+ return 1;
+ }
+
if (len == 5 && !strncmp((const char *)val, "shift", strlen("shift"))) {
config.modifier = ShiftMask;
return 1;
case '3':
config.modifier = Mod3Mask;
return 1;
- /*
- case '4':
- config.modifier = Mod4Mask;
- return 1;
- */
case '5':
config.modifier = Mod5Mask;
return 1;
}
}
+
config.modifier = Mod4Mask;
return 1;
}
if (!strcmp(cur_key, "status_command")) {
DLOG("command = %.*s\n", len, val);
+ FREE(config.command);
sasprintf(&config.command, "%.*s", len, val);
return 1;
}
return 1;
}
+ /* We keep the old single tray_output working for users who only restart i3bar
+ * after updating. */
if (!strcmp(cur_key, "tray_output")) {
- DLOG("tray_output %.*s\n", len, val);
- FREE(config.tray_output);
- sasprintf(&config.tray_output, "%.*s", len, val);
+ DLOG("Found deprecated key tray_output %.*s.\n", len, val);
+ tray_output_t *tray_output = scalloc(1, sizeof(tray_output_t));
+ sasprintf(&(tray_output->output), "%.*s", len, val);
+ TAILQ_INSERT_TAIL(&(config.tray_outputs), tray_output, tray_outputs);
return 1;
}
handle = yajl_alloc(&outputs_callbacks, NULL, NULL);
TAILQ_INIT(&(config.bindings));
+ TAILQ_INIT(&(config.tray_outputs));
state = yajl_parse(handle, (const unsigned char *)json, strlen(json));