diff --git a/config-verify.c b/config-verify.c index 9a0409a..e20f142 100644 --- a/config-verify.c +++ b/config-verify.c @@ -18,6 +18,7 @@ #include "modules/mpd/mpd.h" #include "modules/network/network.h" #include "modules/removables/removables.h" +#include "modules/xkb/xkb.h" const char * conf_err_prefix(const keychain_t *chain, const struct yml_node *node) @@ -439,11 +440,6 @@ verify_module(keychain_t *chain, const struct yml_node *node) return false; } - static const struct attr_info xkb[] = { - {"content", true, &conf_verify_particle}, - {"anchors", false, NULL}, - }; - static const struct attr_info xwindow[] = { {"content", true, &conf_verify_particle}, {"anchors", false, NULL}, @@ -463,6 +459,7 @@ verify_module(keychain_t *chain, const struct yml_node *node) {"mpd", &module_mpd}, {"network", &module_network}, {"removables", &module_removables}, + {"xkb", &module_xkb}, }; static const struct { @@ -470,7 +467,6 @@ verify_module(keychain_t *chain, const struct yml_node *node) const struct attr_info *attrs; size_t count; } modules[] = { - {"xkb", xkb, sizeof(xkb) / sizeof(xkb[0])}, {"xwindow", xwindow, sizeof(xwindow) / sizeof(xwindow[0])}, }; diff --git a/config.c b/config.c index 1d340ba..6be88df 100644 --- a/config.c +++ b/config.c @@ -369,14 +369,6 @@ module_xwindow_from_config(const struct yml_node *node, const struct font *paren return module_xwindow(conf_to_particle(c, parent_font)); } -static struct module * -module_xkb_from_config(const struct yml_node *node, - const struct font *parent_font) -{ - const struct yml_node *c = yml_get_value(node, "content"); - return module_xkb(conf_to_particle(c, parent_font)); -} - struct bar * conf_to_bar(const struct yml_node *bar) { @@ -485,12 +477,12 @@ conf_to_bar(const struct yml_node *bar) mods[idx] = module_network.from_conf(m.value, font); else if (strcmp(mod_name, "removables") == 0) mods[idx] = module_removables.from_conf(m.value, font); + else if (strcmp(mod_name, "xkb") == 0) + mods[idx] = module_xkb.from_conf(m.value, font); else if (strcmp(mod_name, "xwindow") == 0) mods[idx] = module_xwindow_from_config(m.value, font); - else if (strcmp(mod_name, "xkb") == 0) - mods[idx] = module_xkb_from_config(m.value, font); else assert(false); } diff --git a/modules/xkb/xkb.c b/modules/xkb/xkb.c index 48d1854..5410e43 100644 --- a/modules/xkb/xkb.c +++ b/modules/xkb/xkb.c @@ -13,6 +13,7 @@ #define LOG_MODULE "xkb" #include "../../log.h" #include "../../bar.h" +#include "../../config.h" #include "../../xcb.h" struct layout { @@ -436,8 +437,8 @@ run(struct module_run_context *ctx) return ret; } -struct module * -module_xkb(struct particle *label) +static struct module * +xkb_new(struct particle *label) { struct private *m = malloc(sizeof(*m)); m->label = label; @@ -452,3 +453,20 @@ module_xkb(struct particle *label) mod->content = &content; return mod; } + +static struct module * +from_conf(const struct yml_node *node, const struct font *parent_font) +{ + const struct yml_node *c = yml_get_value(node, "content"); + return xkb_new(conf_to_particle(c, parent_font)); +} + +const struct module_info module_xkb = { + .from_conf = &from_conf, + .attr_count = 2, + .attrs = { + {"content", true, &conf_verify_particle}, + {"anchors", false, NULL}, + {NULL, false, NULL}, + }, +}; diff --git a/modules/xkb/xkb.h b/modules/xkb/xkb.h index c23129b..d38743e 100644 --- a/modules/xkb/xkb.h +++ b/modules/xkb/xkb.h @@ -1,5 +1,4 @@ #pragma once #include "../../module.h" -#include "../../particle.h" -struct module *module_xkb(struct particle *label); +extern const struct module_info module_xkb;