Move code clearing the config to a new function
This commit is contained in:
parent
4a2cacebf6
commit
7754de900a
82
src/config.c
82
src/config.c
|
@ -39,45 +39,12 @@ void update_barconfig(void) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds the configuration file to use (either the one specified by
|
||||
* override_configpath), the user’s one or the system default) and calls
|
||||
* parse_file().
|
||||
*
|
||||
*/
|
||||
bool parse_configuration(const char *override_configpath, bool use_nagbar) {
|
||||
char *path = get_config_path(override_configpath, true);
|
||||
if (path == NULL) {
|
||||
die("Unable to find the configuration file (looked at "
|
||||
"$XDG_CONFIG_HOME/i3/config, ~/.i3/config, $XDG_CONFIG_DIRS/i3/config "
|
||||
"and " SYSCONFDIR "/i3/config)");
|
||||
}
|
||||
static void free_configuration(void) {
|
||||
assert(conn != NULL);
|
||||
|
||||
LOG("Parsing configfile %s\n", path);
|
||||
FREE(current_configpath);
|
||||
current_configpath = path;
|
||||
|
||||
/* initialize default bindings if we're just validating the config file */
|
||||
if (!use_nagbar && bindings == NULL) {
|
||||
bindings = scalloc(1, sizeof(struct bindings_head));
|
||||
TAILQ_INIT(bindings);
|
||||
}
|
||||
|
||||
return parse_file(path, use_nagbar);
|
||||
}
|
||||
|
||||
/*
|
||||
* (Re-)loads the configuration file (sets useful defaults before).
|
||||
*
|
||||
* If you specify override_configpath, only this path is used to look for a
|
||||
* configuration file.
|
||||
*
|
||||
*/
|
||||
void load_configuration(const char *override_configpath, bool reload) {
|
||||
if (reload) {
|
||||
/* If we are currently in a binding mode, we first revert to the
|
||||
* default since we have no guarantee that the current mode will even
|
||||
* still exist after parsing the config again. See #2228. */
|
||||
/* If we are currently in a binding mode, we first revert to the default
|
||||
* since we have no guarantee that the current mode will even still exist
|
||||
* after parsing the config again. See #2228. */
|
||||
switch_mode("default");
|
||||
|
||||
/* First ungrab the keys */
|
||||
|
@ -192,6 +159,45 @@ void load_configuration(const char *override_configpath, bool reload) {
|
|||
free(config.fake_outputs);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds the configuration file to use (either the one specified by
|
||||
* override_configpath), the user’s one or the system default) and calls
|
||||
* parse_file().
|
||||
*
|
||||
*/
|
||||
bool parse_configuration(const char *override_configpath, bool use_nagbar) {
|
||||
char *path = get_config_path(override_configpath, true);
|
||||
if (path == NULL) {
|
||||
die("Unable to find the configuration file (looked at "
|
||||
"$XDG_CONFIG_HOME/i3/config, ~/.i3/config, $XDG_CONFIG_DIRS/i3/config "
|
||||
"and " SYSCONFDIR "/i3/config)");
|
||||
}
|
||||
|
||||
LOG("Parsing configfile %s\n", path);
|
||||
FREE(current_configpath);
|
||||
current_configpath = path;
|
||||
|
||||
/* initialize default bindings if we're just validating the config file */
|
||||
if (!use_nagbar && bindings == NULL) {
|
||||
bindings = scalloc(1, sizeof(struct bindings_head));
|
||||
TAILQ_INIT(bindings);
|
||||
}
|
||||
|
||||
return parse_file(path, use_nagbar);
|
||||
}
|
||||
|
||||
/*
|
||||
* (Re-)loads the configuration file (sets useful defaults before).
|
||||
*
|
||||
* If you specify override_configpath, only this path is used to look for a
|
||||
* configuration file.
|
||||
*
|
||||
*/
|
||||
void load_configuration(const char *override_configpath, bool reload) {
|
||||
if (reload) {
|
||||
free_configuration();
|
||||
}
|
||||
|
||||
SLIST_INIT(&modes);
|
||||
|
||||
struct Mode *default_mode = scalloc(1, sizeof(struct Mode));
|
||||
|
|
Loading…
Reference in New Issue