src/main.c: read themerc specified by rc.xml

This commit is contained in:
Johan Malm 2020-07-20 19:53:03 +01:00
parent c38b3ec770
commit d7d838d682
4 changed files with 11 additions and 7 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
*.o
xdg-shell-protocol.*
labwc
build/
build*/
subprojects/

View 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 */

View 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)

View 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) {