about summary refs log tree commit diff stats
path: root/settings.c
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-05-16 16:11:54 -0400
committerJosh Rickmar <jrick@devio.us>2012-05-16 19:33:39 -0400
commit1b1398e0f206ca1e445e5768feda331065ea01f4 (patch)
treeab5ac4474e6b3e4821bf73423a46aed38583b6f9 /settings.c
parentdfe584d1a656f4d95764dd06fa8502aa45b187fe (diff)
downloadxombrero-1b1398e0f206ca1e445e5768feda331065ea01f4.tar.gz
Add a setting to read additional config files from any other config
file and document it.  This fixes FS#238.
Diffstat (limited to 'settings.c')
-rw-r--r--settings.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/settings.c b/settings.c
index 9efae47..b0d773e 100644
--- a/settings.c
+++ b/settings.c
@@ -102,6 +102,7 @@ char		*external_editor = NULL;
 int		referer_mode = XT_REFERER_ALWAYS;
 char		*referer_custom = NULL;
 int		download_notifications = 0;
+char		*include_config = NULL;
 
 char		*cmd_font_name = NULL;
 char		*oops_font_name = NULL;
@@ -392,6 +393,7 @@ struct settings		rs[] = {
 	{ "enable_favicon_tabs",	XT_S_INT, 0,		&enable_favicon_tabs, NULL, NULL, NULL, set_enable_favicon_tabs },
 	{ "referer",			XT_S_STR, 0, NULL, NULL,&s_referer, NULL, set_referer_rt },
 	{ "download_notifications",	XT_S_INT, 0,		&download_notifications, NULL, NULL, NULL, set_download_notifications },
+	{ "include_config",		XT_S_STR, 0, NULL,	&include_config, NULL, NULL, NULL },
 
 	/* font settings */
 	{ "cmd_font",			XT_S_STR, 0, NULL, &cmd_font_name, NULL, NULL, set_cmd_font },
@@ -1981,15 +1983,26 @@ walk_pl_wl(struct settings *s,
 int
 settings_add(char *var, char *val)
 {
-	int i, rv, *p;
-	gfloat *f;
-	char **s;
+	int			i, rv, *p;
+	gfloat			*f;
+	char			c[PATH_MAX], **s;
 
 	/* get settings */
 	for (i = 0, rv = 0; i < LENGTH(rs); i++) {
 		if (strcmp(var, rs[i].name))
 			continue;
 
+		if (!strcmp(var, "include_config")) {
+			if (val[0] == '~')
+				snprintf(c, PATH_MAX, "%s" PS "%s", pwd->pw_dir,
+				    &val[1]);
+			else
+				strlcpy(c, val, PATH_MAX);
+			config_parse(c, 0);
+			rv = 1;
+			break;
+		}
+
 		if (rs[i].s) {
 			if (rs[i].s->set(&rs[i], val))
 				errx(1, "invalid value for %s: %s", var, val);