From d7de348e1f4b02051b668c975265368e1544bbbd Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Sat, 16 May 2020 23:19:54 -0600 Subject: Fix labels for fs node type Labels for the fs node type were previously being written when the load function was called. Now we set this on initial config load and do not override on data load. --- src/config_fs.c | 9 ++++++--- src/config_node.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/config_fs.c b/src/config_fs.c index 45ccd46..aa61f4e 100644 --- a/src/config_fs.c +++ b/src/config_fs.c @@ -27,10 +27,14 @@ void config_fs_init(struct node* n) { void load_fs_key(struct node* n, char* key, char* val) { struct config_fs* data = (struct config_fs*) n->data; - if(strcmp(key, "path") == 0) + if(strcmp(key, "path") == 0) { strcpy(data->path, val); - else + // Provide a default label using the path if one not already specified + if(n->label[0] == '\0') + sprintf(n->label, "%s", val); + } else { printf("ERROR: Unknown fs key %s\n", key); + } } int config_fs_load(struct node* n) { @@ -58,6 +62,5 @@ int config_fs_load(struct node* n) { } else { sprintf(n->text, "%d%%", percent); } - sprintf(n->label, "%s:", ((struct config_fs*)n->data)->path); return 0; } diff --git a/src/config_node.c b/src/config_node.c index dcccc00..16aa0ed 100644 --- a/src/config_node.c +++ b/src/config_node.c @@ -66,7 +66,7 @@ void node_print(struct node* n) { printf("{ \"full_text\":\" %s\", \"color\": \"%s\", \"separator\":false },", n->label, n->label_color); - printf("{ \"full_text\":\" %s \", \"color\":\"%s\" }", n->text, n->color); + printf("{ \"full_text\":\"%s \", \"color\":\"%s\" }", n->text, n->color); if(n->next) printf(","); printf("\n"); -- cgit v1.2.3