]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/main.c: read themerc specified by rc.xml
authorJohan Malm <jgm323@gmail.com>
Mon, 20 Jul 2020 18:53:03 +0000 (19:53 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 20 Jul 2020 18:53:03 +0000 (19:53 +0100)
.gitignore
include/theme.h
src/main.c
src/theme/theme.c

index 81c739b851a7e287e638e92621d8e3b8b99d036c..6cadb84ad9764039232cbbe53ba237c8c46052c9 100644 (file)
@@ -1,5 +1,5 @@
 *.o
 xdg-shell-protocol.*
 labwc
-build/
+build*/
 subprojects/
index 8cb2f72780ecac3fb5a5a822b7378af152237861..f22e9527ba36297eaccd551a1c4874bf818183e6 100644 (file)
@@ -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 */
index 7a3f67e4e7a0ca6dacd4e57ebc349384d801bb07..2e8c39a086707b15d3b33f08df6a3bebfa313403 100644 (file)
@@ -8,7 +8,7 @@ struct rcxml rc = { 0 };
 struct theme theme = { 0 };
 
 static const char labwc_usage[] =
-"Usage: labwc [-h] [-s <startup-command>] [-c <config-file>]\n";
+       "Usage: labwc [-h] [-s <startup-command>] [-c <config-file>]\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)
index 8a44cf4fbf88b0b7074b4e74be18e6eb8bbc293b..99770de5becbc81d93d96d2755cec8bcf026e899 100644 (file)
@@ -5,6 +5,7 @@
 #include <ctype.h>
 
 #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) {