diff options
author | Aaron Ball <nullspoon@oper.io> | 2022-03-18 18:56:10 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2022-03-18 18:56:10 -0600 |
commit | 370f9bd0e1719c3a51bb42d1b1272c8ea8c1501f (patch) | |
tree | 3c02cbc2a14f12b5018e10913abf7dcdc34118ac | |
parent | 247996f237743b0ff2d2288c41affeab93657bfd (diff) | |
download | i3cstat-370f9bd0e1719c3a51bb42d1b1272c8ea8c1501f.tar.gz i3cstat-370f9bd0e1719c3a51bb42d1b1272c8ea8c1501f.tar.xz |
config_time: Support new key, fmt
This key allows the time format to be configurable. The default is '%T',
but some users may not want the seconds or may want additional
information.
-rw-r--r-- | src/config_time.c | 6 | ||||
-rw-r--r-- | src/config_time.h | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/config_time.c b/src/config_time.c index d6931ff..39c8427 100644 --- a/src/config_time.c +++ b/src/config_time.c @@ -22,12 +22,16 @@ void config_time_init(struct node* n) { n->type = CTYPE_TIME; n->loadfunc = &config_time_load; n->loadkey = &load_time_key; + + strcpy(((struct config_time*) n->data)->fmt, "%T"); } void load_time_key(struct node* n, char* key, char* val) { if(strcmp(key, "tz") == 0) strcpy(((struct config_time*) n->data)->tz, val); + else if(strcmp(key, "fmt") == 0) + strcpy(((struct config_time*) n->data)->fmt, val); else printf("ERROR: Unknown time key %s\n", key); } @@ -41,7 +45,7 @@ int config_time_load(struct node* n) { time(&timep); info = localtime(&timep); - strftime(n->text, 256, "%T", info); + strftime(n->text, 256, ((struct config_time*)n->data)->fmt, info); strcpy(n->color, C_DGREY); strcpy(n->label_color, C_LGREY); diff --git a/src/config_time.h b/src/config_time.h index 31155be..e8d1ea1 100644 --- a/src/config_time.h +++ b/src/config_time.h @@ -29,6 +29,7 @@ struct config_time { char tz[256]; + char fmt[128]; }; void config_time_init(struct node*); |