Add/fix "get space_icon_strip"

If no value given when calling `spacebar -m config space_icon_strip`,
print the current value.

Prints icon strip names delimited by spaces and surrounded with double
quotation marks, so it supports space names with spaces.
This commit is contained in:
Oddmund Strømme 2020-10-04 15:31:12 +02:00 committed by Calum MacRae
parent 95ac5d7164
commit e2a53e513b

View file

@ -168,11 +168,20 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACE_STRIP)) {
char **icon_strip = NULL;
struct token token = get_token(&message);
while (token.text && token.length > 0) {
buf_push(icon_strip, token_to_string(token));
token = get_token(&message);
if(token.length==0){ // If no value given, print current value
fprintf(rsp, "\"%s\"", *g_bar_manager._space_icon_strip);
char **p = g_bar_manager._space_icon_strip;
for(int i = 1; i<buf_len(g_bar_manager.space_icon_strip);i++) {
fprintf(rsp, " \"%s\"", *++p);
}
} else { // Else, set value
while (token.text && token.length > 0) {
buf_push(icon_strip, token_to_string(token));
token = get_token(&message);
}
bar_manager_set_space_strip(&g_bar_manager, icon_strip);
}
bar_manager_set_space_strip(&g_bar_manager, icon_strip);
} else if (token_equals(command, COMMAND_CONFIG_BAR_POWER_STRIP)) {
char **icon_strip = NULL;
struct token token = get_token(&message);