Save explicit filename for rc if supplied so reload works correctly

This commit is contained in:
Simon Long 2024-01-05 14:07:19 +00:00
parent 8ef50d9389
commit 86f95bb42f
2 changed files with 12 additions and 1 deletions

View file

@ -1460,7 +1460,12 @@ rcxml_read(const char *filename)
char *line = NULL;
size_t len = 0;
struct buf b;
static char rcxml[4096] = {0};
char rcxml[4096] = {0};
static char saved_filename[4096] = {0};
if (filename) {
snprintf(saved_filename, sizeof(rcxml), "%s", filename);
}
rcxml_init();
@ -1475,6 +1480,9 @@ rcxml_read(const char *filename)
if (filename) {
snprintf(rcxml, sizeof(rcxml), "%s", filename);
i = 0;
} else if (saved_filename[0] != 0) {
snprintf(rcxml, sizeof(rcxml), "%s", saved_filename);
i = 0;
} else {
snprintf(rcxml, sizeof(rcxml), "%s/rc.xml", config_dir_n(i));
}

View file

@ -3,6 +3,7 @@
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include "common/dir.h"
#include "common/fd_util.h"
#include "common/font.h"
@ -135,6 +136,8 @@ main(int argc, char *argv[])
if (!rc.config_dir) {
rc.config_dir = config_dir();
} else if (!config_file) {
config_file = g_strdup_printf ("%s/rc.xml", rc.config_dir);
}
wlr_log(WLR_INFO, "using config dir (%s)\n", rc.config_dir);
session_environment_init(rc.config_dir);