i3bar: only restart child when command changed (#2866)
this is a follow-up to
98f202dd1b
fixes #2689
This commit is contained in:
parent
c70fa8078f
commit
fdb551f9d5
|
@ -185,6 +185,7 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
|
||||||
|
|
||||||
if (!strcmp(cur_key, "status_command")) {
|
if (!strcmp(cur_key, "status_command")) {
|
||||||
DLOG("command = %.*s\n", len, val);
|
DLOG("command = %.*s\n", len, val);
|
||||||
|
FREE(config.command);
|
||||||
sasprintf(&config.command, "%.*s", len, val);
|
sasprintf(&config.command, "%.*s", len, val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,6 @@ void got_bar_config(char *reply) {
|
||||||
init_colors(&(config.colors));
|
init_colors(&(config.colors));
|
||||||
|
|
||||||
start_child(config.command);
|
start_child(config.command);
|
||||||
FREE(config.command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data structure to easily call the reply handlers later */
|
/* Data structure to easily call the reply handlers later */
|
||||||
|
@ -178,6 +177,7 @@ void got_bar_config_update(char *event) {
|
||||||
|
|
||||||
/* update the configuration with the received settings */
|
/* update the configuration with the received settings */
|
||||||
DLOG("Received bar config update \"%s\"\n", event);
|
DLOG("Received bar config update \"%s\"\n", event);
|
||||||
|
char *old_command = sstrdup(config.command);
|
||||||
bar_display_mode_t old_mode = config.hide_on_modifier;
|
bar_display_mode_t old_mode = config.hide_on_modifier;
|
||||||
parse_config_json(event);
|
parse_config_json(event);
|
||||||
if (old_mode != config.hide_on_modifier) {
|
if (old_mode != config.hide_on_modifier) {
|
||||||
|
@ -189,9 +189,11 @@ void got_bar_config_update(char *event) {
|
||||||
init_colors(&(config.colors));
|
init_colors(&(config.colors));
|
||||||
|
|
||||||
/* restart status command process */
|
/* restart status command process */
|
||||||
|
if (strcmp(old_command, config.command) != 0) {
|
||||||
kill_child();
|
kill_child();
|
||||||
start_child(config.command);
|
start_child(config.command);
|
||||||
FREE(config.command);
|
}
|
||||||
|
free(old_command);
|
||||||
|
|
||||||
draw_bars(false);
|
draw_bars(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue