diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-08-15 16:15:43 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-08-15 16:15:43 +0000 |
| commit | 9fe6e8cc4850ea9dd14245ae9563ceaf12f810c6 (patch) | |
| tree | 80ff5885b52edf624d110bde30e6cc98df3b4a2f /config.c | |
| parent | font: don't bother creating a cairo surface for zero-width glyphs (diff) | |
Add background alpha support
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -120,6 +120,19 @@ str_to_ulong(const char *s, int base, unsigned long *res) } static bool +str_to_double(const char *s, double *res) +{ + if (s == NULL) + return false; + + errno = 0; + char *end = NULL; + + *res = strtod(s, &end); + return errno == 0 && *end == '\0'; +} + +static bool str_to_color(const char *s, uint32_t *color, const char *path, int lineno) { unsigned long value; @@ -203,6 +216,17 @@ parse_section_colors(const char *key, const char *value, struct config *conf, else if (strcmp(key, "bright5") == 0) color = &conf->colors.bright[5]; else if (strcmp(key, "bright6") == 0) color = &conf->colors.bright[6]; else if (strcmp(key, "bright7") == 0) color = &conf->colors.bright[7]; + else if (strcmp(key, "alpha") == 0) { + double alpha; + if (!str_to_double(value, &alpha) || alpha < 0. || alpha > 1.) { + LOG_ERR("%s: %d: alpha: expected a value in the range 0.0-1.0", + path, lineno); + return false; + } + + conf->colors.alpha = alpha; + return true; + } else { LOG_ERR("%s:%d: invalid key: %s", path, lineno, key); @@ -442,6 +466,7 @@ config_load(struct config *conf) default_bright[6], default_bright[7], }, + .alpha = 1., }, .cursor = { |
