From d7d838d682bb192da95cff503e50710180eab23c Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Mon, 20 Jul 2020 19:53:03 +0100 Subject: [PATCH] src/main.c: read themerc specified by rc.xml --- .gitignore | 2 +- include/theme.h | 2 +- src/main.c | 4 ++-- src/theme/theme.c | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 81c739b8..6cadb84a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.o xdg-shell-protocol.* labwc -build/ +build*/ subprojects/ diff --git a/include/theme.h b/include/theme.h index 8cb2f727..f22e9527 100644 --- a/include/theme.h +++ b/include/theme.h @@ -21,6 +21,6 @@ struct theme { extern struct theme theme; -void theme_read(const char *filename); +void theme_read(const char *theme_name); #endif /* THEME_H */ diff --git a/src/main.c b/src/main.c index 7a3f67e4..2e8c39a0 100644 --- a/src/main.c +++ b/src/main.c @@ -8,7 +8,7 @@ struct rcxml rc = { 0 }; struct theme theme = { 0 }; static const char labwc_usage[] = -"Usage: labwc [-h] [-s ] [-c ]\n"; + "Usage: labwc [-h] [-s ] [-c ]\n"; static void usage(void) { @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) server_init(&server); server_start(&server); - theme_read("data/themerc"); + theme_read(rc.theme_name); xbm_load(server.renderer); if (startup_cmd) diff --git a/src/theme/theme.c b/src/theme/theme.c index 8a44cf4f..99770de5 100644 --- a/src/theme/theme.c +++ b/src/theme/theme.c @@ -5,6 +5,7 @@ #include #include "theme.h" +#include "theme/theme-dir.h" static int hex_to_dec(char c) { @@ -80,15 +81,18 @@ static void process_line(char *line) entry(key, value); } -void theme_read(const char *filename) +void theme_read(const char *theme_name) { FILE *stream; char *line = NULL; size_t len = 0; + char themerc[4096]; - stream = fopen(filename, "r"); + snprintf(themerc, sizeof(themerc), "%s/themerc", theme_dir(theme_name)); + fprintf(stderr, "info: read themerc (%s)\n", themerc); + stream = fopen(themerc, "r"); if (!stream) { - fprintf(stderr, "warn: cannot read '%s'\n", filename); + fprintf(stderr, "warn: cannot read (%s)\n", themerc); return; } while (getline(&line, &len, stream) != -1) { -- 2.52.0