diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-16 09:52:22 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-16 09:52:22 +0000 |
| commit | 0d1b4449b9268ad008852d38d3f7df544db7a410 (patch) | |
| tree | 5cc470aa900c2f09812f331412940135025631d5 /main.c | |
| parent | main: default font is 'monospace' (diff) | |
conf: initial support for configuration file
* Look for configuration file in (in this order):
- XDG_CONFIG_HOME/footrc
- ~/.config/footrc
* Currently supports setting the font
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -19,15 +19,16 @@ #define LOG_ENABLE_DBG 0 #include "log.h" +#include "config.h" #include "font.h" #include "grid.h" #include "input.h" #include "render.h" +#include "selection.h" #include "shm.h" #include "slave.h" #include "terminal.h" #include "vt.h" -#include "selection.h" #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) @@ -264,12 +265,14 @@ main(int argc, char *const *argv) { int ret = EXIT_FAILURE; + struct config conf = config_load(); + static const struct option longopts[] = { {"font", required_argument, 0, 'f'}, {NULL, no_argument, 0, 0}, }; - const char *font_name = "monospace"; + //const char *font_name = "monospace"; while (true) { int c = getopt_long(argc, argv, ":f:h", longopts, NULL); @@ -278,7 +281,8 @@ main(int argc, char *const *argv) switch (c) { case 'f': - font_name = optarg; + free(conf.font); + conf.font = strdup(optarg); break; case 'h': @@ -340,19 +344,19 @@ main(int argc, char *const *argv) thrd_t keyboard_repeater_id; thrd_create(&keyboard_repeater_id, &keyboard_repeater, &term); - term.fonts[0] = font_from_name(font_name); + term.fonts[0] = font_from_name(conf.font); if (term.fonts[0] == NULL) goto out; { char fname[1024]; - snprintf(fname, sizeof(fname), "%s:style=bold", font_name); + snprintf(fname, sizeof(fname), "%s:style=bold", conf.font); term.fonts[1] = font_from_name(fname); - snprintf(fname, sizeof(fname), "%s:style=italic", font_name); + snprintf(fname, sizeof(fname), "%s:style=italic", conf.font); term.fonts[2] = font_from_name(fname); - snprintf(fname, sizeof(fname), "%s:style=bold italic", font_name); + snprintf(fname, sizeof(fname), "%s:style=bold italic", conf.font); term.fonts[3] = font_from_name(fname); } @@ -703,6 +707,8 @@ out: close(term.kbd.repeat.pipe_read_fd); close(term.kbd.repeat.pipe_write_fd); + config_free(conf); + cairo_debug_reset_static_data(); return ret; } |
