diff options
| author | Federico Angelilli <code@fedang.net> | 2024-07-10 23:49:13 +0200 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-07-10 23:49:13 +0200 |
| commit | 26aaffc0e7293e4d4e48362159572e205c082068 (patch) | |
| tree | cbc55034ab2c6756ee633da1c171209c0535ea81 /src/comet.c | |
| parent | 6f7c05c10766be1e331a5668ef534f5e85cecace (diff) | |
Finish config reader
Diffstat (limited to 'src/comet.c')
| -rw-r--r-- | src/comet.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/comet.c b/src/comet.c index be76621..c0343e0 100644 --- a/src/comet.c +++ b/src/comet.c @@ -39,10 +39,17 @@ int main(int argc, char **argv) setlocale(LC_CTYPE, ""); any_log_init(stdout, ANY_LOG_DEBUG); - FILE *config_file = fopen("comet.conf", "rb"); - config_t config; - config_init(&config, config_file); + config_init(&config); + log_debug("Copied default config"); + + const char *config_path = "comet.conf"; + FILE *config_file = fopen(config_path, "rb"); + + if (config_file != NULL) { + log_debug("Reading config '%s'", config_path); + config_read(&config, config_file); + } display_t display; display_init(&display); @@ -53,14 +60,11 @@ int main(int argc, char **argv) int x_padding = 10; int y_padding = 8; - //int height = 30; - //int width = display.screen_size->width - 2 * x_padding; - - const char *font = "Hack 12"; - log_debug("Loading font '%s'", font); + log_debug("Loading font '%s'", config.font); + PangoFontDescription *fontdesc = pango_font_description_from_string(config.font); layout_info_t info = { - .fontdesc = pango_font_description_from_string(font), + .fontdesc = fontdesc, .context = pango_cairo_create_context(window.cr), .x_offset = 0, .height = config.height, @@ -131,6 +135,7 @@ int main(int argc, char **argv) window_close(&window); display_close(&display); + config_free(&config); return 0; } |
