From 777a7ce624426c7ed94f062a825709925c96fc7d Mon Sep 17 00:00:00 2001 From: Simon Long Date: Fri, 5 Jan 2024 23:00:20 +0000 Subject: [PATCH] Add -m option to enable merging of config --- src/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index de31b52b..7107e941 100644 --- a/src/main.c +++ b/src/main.c @@ -22,6 +22,7 @@ static const struct option long_options[] = { {"debug", no_argument, NULL, 'd'}, {"exit", no_argument, NULL, 'e'}, {"help", no_argument, NULL, 'h'}, + {"mergeconfig", no_argument, NULL, 'm'}, {"reconfigure", no_argument, NULL, 'r'}, {"startup", required_argument, NULL, 's'}, {"version", no_argument, NULL, 'v'}, @@ -36,6 +37,7 @@ static const char labwc_usage[] = " -d, --debug Enable full logging, including debug information\n" " -e, --exit Exit the compositor\n" " -h, --help Show help message and quit\n" +" -m, --mergeconfig Merge user rc.xml with system rc.xml\n" " -r, --reconfigure Reload the compositor configuration\n" " -s, --startup Run command on startup\n" " -v, --version Show version number and quit\n" @@ -88,11 +90,12 @@ main(int argc, char *argv[]) char *startup_cmd = NULL; char *config_file = NULL; enum wlr_log_importance verbosity = WLR_ERROR; + bool merge_rc = false; int c; while (1) { int index = 0; - c = getopt_long(argc, argv, "c:C:dehrs:vV", long_options, &index); + c = getopt_long(argc, argv, "c:C:dehmrs:vV", long_options, &index); if (c == -1) { break; } @@ -121,6 +124,9 @@ main(int argc, char *argv[]) case 'V': verbosity = WLR_INFO; break; + case 'm': + merge_rc = true; + break; case 'h': default: usage(); @@ -136,6 +142,9 @@ main(int argc, char *argv[]) if (!rc.config_dir) { rc.config_dir = config_dir(); + if (merge_rc == false && !config_file) { + config_file = g_strdup_printf("%s/rc.xml", rc.config_dir); + } } else if (!config_file) { config_file = g_strdup_printf("%s/rc.xml", rc.config_dir); }