summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-26 12:31:53 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-26 16:37:50 +0100
commit71a5350b681e022e9738b50f2977ddb529110bfb (patch)
tree4c199980a9f80c07d69130a72402a5cfe2a8a63f /include
parentUpdate README.md (diff)
downloadsway-71a5350b681e022e9738b50f2977ddb529110bfb.tar.gz
sway-71a5350b681e022e9738b50f2977ddb529110bfb.tar.zst
sway-71a5350b681e022e9738b50f2977ddb529110bfb.zip
Implement include command
The include command (`include <path>`) 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
Diffstat (limited to 'include')
-rw-r--r--include/config.h20
1 files changed, 16 insertions, 4 deletions
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 {
184 bool smart_gaps; 184 bool smart_gaps;
185 int gaps_inner; 185 int gaps_inner;
186 int gaps_outer; 186 int gaps_outer;
187
188 list_t *config_chain;
189 const char *current_config;
187}; 190};
188 191
189/** 192/**
190 * Loads the config from the given path. 193 * Loads the main config from the given path. is_active should be true when
194 * reloading the config.
191 */ 195 */
192bool load_config(const char *file); 196bool load_main_config(const char *path, bool is_active);
193/** Reads the config from the given FILE. 197
198/**
199 * Loads an included config. Can only be used after load_main_config.
194 */ 200 */
195bool read_config(FILE *file, bool is_active); 201bool load_include_configs(const char *path, struct sway_config *config);
202
203/**
204 * Reads the config from the given FILE.
205 */
206bool read_config(FILE *file, struct sway_config *config);
207
196/** 208/**
197 * Free config struct 209 * Free config struct
198 */ 210 */