X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fconfig.c;h=6f906b8ce02e7218828ae2f449bf3223a82dd205;hb=fa93f275bb03462e6d236fd50da0b96ddbd690da;hp=781ff6b83b7a00cf12f2dc084941381cbb1b0ed0;hpb=4c06e7a573e450329212b28a3b8f4a5e89b326d4;p=i3%2Fi3 diff --git a/src/config.c b/src/config.c index 781ff6b8..6f906b8c 100644 --- a/src/config.c +++ b/src/config.c @@ -11,9 +11,7 @@ * */ #include "all.h" - -/* We need Xlib for XStringToKeysym */ -#include +#include char *current_configpath = NULL; Config config; @@ -114,12 +112,19 @@ static char *get_config_path(const char *override_configpath) { * parse_file(). * */ -static void parse_configuration(const char *override_configpath) { +bool parse_configuration(const char *override_configpath, bool use_nagbar) { char *path = get_config_path(override_configpath); LOG("Parsing configfile %s\n", path); FREE(current_configpath); current_configpath = path; - parse_file(path); + + /* initialize default bindings if we're just validating the config file */ + if (!use_nagbar && bindings == NULL) { + bindings = scalloc(sizeof(struct bindings_head)); + TAILQ_INIT(bindings); + } + + return parse_file(path, use_nagbar); } /* @@ -142,9 +147,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, while (!TAILQ_EMPTY(bindings)) { bind = TAILQ_FIRST(bindings); TAILQ_REMOVE(bindings, bind, bindings); - FREE(bind->translated_to); - FREE(bind->command); - FREE(bind); + binding_free(bind); } FREE(bindings); SLIST_REMOVE(&modes, mode, Mode, modes); @@ -155,8 +158,6 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, assign = TAILQ_FIRST(&assignments); if (assign->type == A_TO_WORKSPACE) FREE(assign->dest.workspace); - else if (assign->type == A_TO_OUTPUT) - FREE(assign->dest.output); else if (assign->type == A_COMMAND) FREE(assign->dest.command); match_free(&(assign->match)); @@ -262,7 +263,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, if (config.workspace_urgency_timer == 0) config.workspace_urgency_timer = 0.5; - parse_configuration(override_configpath); + parse_configuration(override_configpath, true); if (reload) { translate_keysyms();