{
va_list params;
fprintf(stderr, LABWC_COLOR_RED);
- fprintf(stderr, "[labwc] warning: ");
+ fprintf(stderr, "[labwc] ");
va_start(params, err);
vfprintf(stderr, err, params);
va_end(params);
set_title_height();
}
-static void rcxml_path(char *buf, size_t len, const char *filename)
+static void rcxml_path(char *buf, size_t len)
{
- if (filename)
- snprintf(buf, len, "%s", filename);
- else
- snprintf(buf, len, "%s/rc.xml", config_dir());
+ if (!strlen(config_dir()))
+ return;
+ snprintf(buf, len, "%s/rc.xml", config_dir());
}
void rcxml_read(const char *filename)
char *line = NULL;
size_t len = 0;
struct buf b;
- char rcxml[4096];
+ char rcxml[4096] = { 0 };
rcxml_init();
wl_list_init(&rc.keybinds);
* Reading file into buffer before parsing makes it easier to write
* unit tests.
*/
- rcxml_path(rcxml, sizeof(rcxml), filename);
- info("reading config file (%s)", rcxml);
+ if (filename)
+ snprintf(rcxml, sizeof(rcxml), "%s", filename);
+ else
+ rcxml_path(rcxml, sizeof(rcxml));
+ if (rcxml[0] == '\0') {
+ warn("cannot find rc.xml config file");
+ goto no_config;
+ }
stream = fopen(rcxml, "r");
if (!stream) {
warn("cannot read (%s)", rcxml);
- goto out;
+ goto no_config;
}
+ info("reading config file (%s)", rcxml);
buf_init(&b);
while (getline(&line, &len, stream) != -1) {
char *p = strrchr(line, '\n');
fclose(stream);
rcxml_parse_xml(&b);
free(b.buf);
-out:
+no_config:
post_processing();
}
void theme_read(const char *theme_name)
{
- FILE *stream;
+ FILE *stream = NULL;
char *line = NULL;
size_t len = 0;
char themerc[4096];
- snprintf(themerc, sizeof(themerc), "%s/themerc", theme_dir(theme_name));
- info("reading themerc (%s)", themerc);
- stream = fopen(themerc, "r");
+ if (strlen(theme_dir(theme_name))) {
+ snprintf(themerc, sizeof(themerc), "%s/themerc",
+ theme_dir(theme_name));
+ stream = fopen(themerc, "r");
+ }
if (!stream) {
- warn("cannot read (%s) - load built-in theme", themerc);
+ warn("cannot find theme (%s), using built-in", theme_name);
theme_builtin();
return;
}
+ info("reading themerc (%s)", themerc);
while (getline(&line, &len, stream) != -1) {
char *p = strrchr(line, '\n');
if (p)