Allow multiple tray_output directives.
This patch introduces the possibility to specify the tray_output directive multiple times. All values will be used by i3bar, in the order they are given. This way, a single bar configuration can be used for several machines with internal output names "eDP1" and "LVDS-0" by specifying tray_output for both. Any external output (e.g., "DP-0") will still not receive the tray. The same effect can be achieved by using "primary", but forces the user to couple the tray display to the primary output which may not be desirable behavior. relates to #555
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
|
||||
static char *cur_key;
|
||||
static bool parsing_bindings;
|
||||
static bool parsing_tray_outputs;
|
||||
|
||||
/*
|
||||
* Parse a key.
|
||||
@ -32,14 +33,20 @@ static int config_map_key_cb(void *params_, const unsigned char *keyVal, size_t
|
||||
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;
|
||||
}
|
||||
|
||||
@ -90,6 +97,14 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
|
||||
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
|
||||
@ -195,10 +210,13 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
|
||||
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;
|
||||
}
|
||||
|
||||
@ -317,6 +335,7 @@ void parse_config_json(char *json) {
|
||||
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));
|
||||
|
||||
|
Reference in New Issue
Block a user