Enable the use of flash as visual bell

With this patch we can configure flash in the bell section.
The colors section allow now to configure the color of the flash and the
alpha to apply to.

Default values are the values which where currently used for flash,
altough I personally like a nice red (eb1313) better.
This commit is contained in:
Raimund Sacherer 2023-10-07 19:37:04 +02:00
parent 56d5d4cc21
commit 36ed07788e
7 changed files with 57 additions and 2 deletions

View file

@ -1031,6 +1031,8 @@ parse_section_bell(struct context *ctx)
return value_to_bool(ctx, &conf->bell.urgent);
else if (strcmp(key, "notify") == 0)
return value_to_bool(ctx, &conf->bell.notify);
else if (strcmp(key, "flash") == 0)
return value_to_bool(ctx, &conf->bell.flash);
else if (strcmp(key, "command") == 0)
return value_to_spawn_template(ctx, &conf->bell.command);
else if (strcmp(key, "command-focused") == 0)
@ -1214,6 +1216,7 @@ parse_section_colors(struct context *ctx)
return true;
}
else if (strcmp(key, "flash") == 0) color = &conf->colors.flash;
else if (strcmp(key, "foreground") == 0) color = &conf->colors.fg;
else if (strcmp(key, "background") == 0) color = &conf->colors.bg;
else if (strcmp(key, "selection-foreground") == 0) color = &conf->colors.selection_fg;
@ -1297,6 +1300,21 @@ parse_section_colors(struct context *ctx)
return true;
}
else if (strcmp(key, "flash_alpha") == 0) {
float alpha;
if (!value_to_float(ctx, &alpha))
return false;
if (alpha < 0. || alpha > 1.) {
LOG_CONTEXTUAL_ERR("not in range 0.0-1.0");
return false;
}
conf->colors.flash_alpha = alpha * 65535.;
return true;
}
else {
LOG_CONTEXTUAL_ERR("not valid option");
return false;
@ -2948,6 +2966,7 @@ config_load(struct config *conf, const char *conf_path,
.bell = {
.urgent = false,
.notify = false,
.flash = false,
.command = {
.argv = {.args = NULL},
},
@ -2971,6 +2990,8 @@ config_load(struct config *conf, const char *conf_path,
.colors = {
.fg = default_foreground,
.bg = default_background,
.flash = 0x7f7f00,
.flash_alpha = 0x7fff,
.alpha = 0xffff,
.selection_fg = 0x80000000, /* Use default bg */
.selection_bg = 0x80000000, /* Use default fg */