From 71a5350b681e022e9738b50f2977ddb529110bfb Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Sat, 26 Mar 2016 12:31:53 +0100 Subject: Implement include command The include command (`include `) makes it possible to include sub config files from the main config file (or from within other sub config files). The include command uses the following rules for including config files: * the `path` can be either a full path or a path that is relative to the parent config. Shell expansion is supported, so it's possible to do `include ~/.config/sway.d/*`. * The same config file can only be included once (to prevent include cycles). If a config is included multiple times it will just be ignored after it has been included once. * Including a sub config file is the same as inserting the content of that file into the parent config, thus rules about overwriting bindsyms etc. works the same as for a single config. Implement #542 --- include/config.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'include/config.h') diff --git a/include/config.h b/include/config.h index 9356140d..4bcf55e8 100644 --- a/include/config.h +++ b/include/config.h @@ -184,15 +184,27 @@ struct sway_config { bool smart_gaps; int gaps_inner; int gaps_outer; + + list_t *config_chain; + const char *current_config; }; /** - * Loads the config from the given path. + * Loads the main config from the given path. is_active should be true when + * reloading the config. */ -bool load_config(const char *file); -/** Reads the config from the given FILE. +bool load_main_config(const char *path, bool is_active); + +/** + * Loads an included config. Can only be used after load_main_config. */ -bool read_config(FILE *file, bool is_active); +bool load_include_configs(const char *path, struct sway_config *config); + +/** + * Reads the config from the given FILE. + */ +bool read_config(FILE *file, struct sway_config *config); + /** * Free config struct */ -- cgit v1.2.3-54-g00ecf