diff options
author | Aaron Ball <nullspoon@oper.io> | 2020-05-16 23:19:54 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2020-05-16 23:19:54 -0600 |
commit | d7de348e1f4b02051b668c975265368e1544bbbd (patch) | |
tree | 07c3bae2fdc0e9d00c840037a760226ba8e8e041 | |
parent | 3350ce6f2546c5d8891074e21b0d4971c6ffca8c (diff) | |
download | i3cstat-d7de348e1f4b02051b668c975265368e1544bbbd.tar.gz i3cstat-d7de348e1f4b02051b668c975265368e1544bbbd.tar.xz |
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.
-rw-r--r-- | src/config_fs.c | 9 | ||||
-rw-r--r-- | 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"); |