aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorRyan Farley <ryan.farley@gmx.com>2021-06-11 09:40:08 +0000
committerRyan Farley <ryan.farley@gmx.com>2021-06-12 08:05:15 +0000
commitf379ffb8ed9bba0dafc2a7c1430ccb1a2517f99c (patch)
tree6d58546ee4af49d67b94e0013c6436e85ef81a70 /main.c
parentMerge branch 'no-conf-found-is-not-an-error' (diff)
Override options from command line
Allow any configuration option to be overridden with -o/--override 'section.key=value' arguments, as suggested in #554 update completitions for override slight refactoring to ease footclient support
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/main.c b/main.c
index 82795424..52ebaca6 100644
--- a/main.c
+++ b/main.c
@@ -62,6 +62,7 @@ print_usage(const char *prog_name)
"Options:\n"
" -c,--config=PATH load configuration from PATH ($XDG_CONFIG_HOME/foot/foot.ini)\n"
" -C,--check-config verify configuration, exit with 0 if ok, otherwise exit with 1\n"
+ " -o,--override [section.]key=value override configuration option\n"
" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
" -t,--term=TERM value to set the environment variable TERM to (%s)\n"
" -T,--title=TITLE initial window title (foot)\n"
@@ -165,6 +166,7 @@ main(int argc, char *const *argv)
static const struct option longopts[] = {
{"config", required_argument, NULL, 'c'},
{"check-config", no_argument, NULL, 'C'},
+ {"override", required_argument, NULL, 'o'},
{"term", required_argument, NULL, 't'},
{"title", required_argument, NULL, 'T'},
{"app-id", required_argument, NULL, 'a'},
@@ -210,9 +212,11 @@ main(int argc, char *const *argv)
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
bool log_syslog = true;
user_notifications_t user_notifications = tll_init();
+ config_override_t overrides = tll_init();
while (true) {
- int c = getopt_long(argc, argv, "+c:Ct:T:a:LD:f:w:W:s::HmFPp:d:l::Svh", longopts, NULL);
+ int c = getopt_long(argc, argv, "+c:Co:t:T:a:LD:f:w:W:s::HmFPp:d:l::Svh", longopts, NULL);
+
if (c == -1)
break;
@@ -225,6 +229,10 @@ main(int argc, char *const *argv)
check_config = true;
break;
+ case 'o':
+ tll_push_back(overrides, optarg);
+ break;
+
case 't':
conf_term = optarg;
break;
@@ -404,7 +412,9 @@ main(int argc, char *const *argv)
}
struct config conf = {NULL};
- if (!config_load(&conf, conf_path, &user_notifications, check_config)) {
+ bool conf_successful = config_load(&conf, conf_path, &user_notifications, &overrides, check_config);
+ tll_free(overrides);
+ if (!conf_successful) {
config_free(conf);
return ret;
}