diff options
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c index 76551fa..38413f4 100644 --- a/src/config.c +++ b/src/config.c @@ -39,6 +39,7 @@ static const config_entry_t block_entries[] = { { "y-padding", CONFIG_INT, NULL, offsetof(block_t, y_padding) }, { "min-width", CONFIG_INT, NULL, offsetof(block_t, min_width) }, { "max-width", CONFIG_INT, NULL, offsetof(block_t, max_width) }, + { "interval", CONFIG_TIME, NULL, offsetof(block_t, update_interval) }, { 0 }, }; @@ -183,6 +184,19 @@ static bool config_read_enum(const char *value, config_enum_t *data, int *result return false; } +static bool config_read_time(const char *value, struct timespec *result) +{ + unsigned int ms; + if (config_read_uint(value, &ms)) { + result->tv_sec = ms / 1000; + result->tv_nsec = (ms % 1000) * 1000000; + return true; + } + + log_debug("Invalid time '%s'", value); + return false; +} + static config_status_t config_read_entry(const config_entry_t *entries, void *result, const char **type, const char *section, const char *key, const char *value) { @@ -256,6 +270,13 @@ static config_status_t config_read_entry(const config_entry_t *entries, void *re } break; + case CONFIG_TIME: + if (config_read_time(value, (struct timespec *)result)) { + log_debug("Set '%s.%s' to '%s'", section, key, value); + return CONFIG_SUCCESS; + } + break; + default: unreachable(); } @@ -384,7 +405,6 @@ void config_read(config_t *config, FILE *file) "s:value", value, "i:line", ini.line); - const char *type; config_status_t status; |
