mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-22 12:25:38 +02:00
parent
318965b715
commit
0cde404d2a
2 changed files with 27 additions and 0 deletions
|
@ -18,6 +18,8 @@
|
|||
* YAML parsing error messages being replaced with a generic _“unknown
|
||||
error”_.
|
||||
* Memory leak when a YAML parsing error was encountered.
|
||||
* clock: update every second when necessary
|
||||
(https://codeberg.org/dnkl/yambar/issues/12).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <sys/time.h>
|
||||
|
||||
#define LOG_MODULE "clock"
|
||||
#define LOG_ENABLE_DBG 0
|
||||
#include "../log.h"
|
||||
#include "../bar/bar.h"
|
||||
#include "../config.h"
|
||||
|
@ -129,8 +130,32 @@ clock_new(struct particle *label, const char *date_format, const char *time_form
|
|||
m->label = label;
|
||||
m->date_format = strdup(date_format);
|
||||
m->time_format = strdup(time_format);
|
||||
|
||||
static const char *const seconds_formatters[] = {
|
||||
"%c",
|
||||
"%s",
|
||||
"%S",
|
||||
"%T",
|
||||
"%r",
|
||||
"%X",
|
||||
};
|
||||
|
||||
m->update_granularity = UPDATE_GRANULARITY_MINUTES;
|
||||
|
||||
for (size_t i = 0;
|
||||
i < sizeof(seconds_formatters) / sizeof(seconds_formatters[0]);
|
||||
i++)
|
||||
{
|
||||
if (strstr(time_format, seconds_formatters[i]) != NULL) {
|
||||
m->update_granularity = UPDATE_GRANULARITY_SECONDS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DBG("using %s update granularity",
|
||||
(m->update_granularity == UPDATE_GRANULARITY_MINUTES
|
||||
? "minutes" : "seconds"));
|
||||
|
||||
struct module *mod = module_common_new();
|
||||
mod->private = m;
|
||||
mod->run = &run;
|
||||
|
|
Loading…
Add table
Reference in a new issue