mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-29 06:46:35 -04:00
enhanced bell configuration
Add a separate section for bell configuration, with a bell-specific command option and a setting to allow that command to run without regard to keyboard focus (for those of us who enjoy being beeped at at all times, for example). The actions are also no longer mutually exclusive; this is primarily anticipating urgency support which cannot be replicated outside the process (in server mode anyway) and would thus be complementary to any notification or arbitrary command.
This commit is contained in:
parent
8cb95018c0
commit
9b9f08a492
6 changed files with 125 additions and 54 deletions
66
config.c
66
config.c
|
|
@ -594,18 +594,33 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
|||
}
|
||||
|
||||
else if (strcmp(key, "bell") == 0) {
|
||||
if (strcmp(value, "set-urgency") == 0)
|
||||
conf->bell_action = BELL_ACTION_URGENT;
|
||||
else if (strcmp(value, "notify") == 0)
|
||||
conf->bell_action = BELL_ACTION_NOTIFY;
|
||||
else if (strcmp(value, "none") == 0)
|
||||
conf->bell_action = BELL_ACTION_NONE;
|
||||
LOG_WARN("deprecated: %s:%d: [default]: bell: set actions in section '[bell]' instead", path, lineno);
|
||||
|
||||
const char fmt[] = "%s:%d \033[1mbell\033[21m, use section \033[1m[bell]\033[21m instead";
|
||||
char *text = xasprintf(fmt, path, lineno);
|
||||
|
||||
struct user_notification deprecation = {
|
||||
.kind = USER_NOTIFICATION_DEPRECATED,
|
||||
.text = text,
|
||||
};
|
||||
tll_push_back(conf->notifications, deprecation);
|
||||
|
||||
if (strcmp(value, "set-urgency") == 0) {
|
||||
memset(&conf->bell, 0, sizeof(conf->bell));
|
||||
conf->bell.urgent = true;
|
||||
}
|
||||
else if (strcmp(value, "notify") == 0) {
|
||||
memset(&conf->bell, 0, sizeof(conf->bell));
|
||||
conf->bell.notify = true;
|
||||
}
|
||||
else if (strcmp(value, "none") == 0) {
|
||||
memset(&conf->bell, 0, sizeof(conf->bell));
|
||||
}
|
||||
else {
|
||||
LOG_AND_NOTIFY_ERR(
|
||||
"%s:%d: [default]: bell: "
|
||||
"%s%d: [default]: bell: "
|
||||
"expected either 'set-urgency', 'notify' or 'none'",
|
||||
path, lineno);
|
||||
conf->bell_action = BELL_ACTION_NONE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -788,6 +803,28 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_section_bell(const char *key, const char *value, struct config *conf,
|
||||
const char *path, unsigned lineno)
|
||||
{
|
||||
if (strcmp(key, "urgent") == 0)
|
||||
conf->bell.urgent = str_to_bool(value);
|
||||
else if (strcmp(key, "notify") == 0)
|
||||
conf->bell.notify = str_to_bool(value);
|
||||
else if (strcmp(key, "command") == 0) {
|
||||
if (!str_to_spawn_template(conf, value, &conf->bell.command, path, lineno, "bell", key))
|
||||
return false;
|
||||
}
|
||||
else if (strcmp(key, "command-focused") == 0)
|
||||
conf->bell.command_focused = str_to_bool(value);
|
||||
else {
|
||||
LOG_AND_NOTIFY_ERR("%s:%u: [bell]: %s: invalid key", path, lineno, key);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_section_scrollback(const char *key, const char *value, struct config *conf,
|
||||
const char *path, unsigned lineno)
|
||||
|
|
@ -1864,6 +1901,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar
|
|||
{
|
||||
enum section {
|
||||
SECTION_MAIN,
|
||||
SECTION_BELL,
|
||||
SECTION_SCROLLBACK,
|
||||
SECTION_COLORS,
|
||||
SECTION_CURSOR,
|
||||
|
|
@ -1887,6 +1925,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar
|
|||
const char *name;
|
||||
} section_info[] = {
|
||||
[SECTION_MAIN] = {&parse_section_main, "main"},
|
||||
[SECTION_BELL] = {&parse_section_bell, "bell"},
|
||||
[SECTION_SCROLLBACK] = {&parse_section_scrollback, "scrollback"},
|
||||
[SECTION_COLORS] = {&parse_section_colors, "colors"},
|
||||
[SECTION_CURSOR] = {&parse_section_cursor, "cursor"},
|
||||
|
|
@ -2212,7 +2251,6 @@ config_load(struct config *conf, const char *conf_path,
|
|||
.enabled = false,
|
||||
.palette_based = false,
|
||||
},
|
||||
.bell_action = BELL_ACTION_NONE,
|
||||
.startup_mode = STARTUP_WINDOWED,
|
||||
.fonts = {tll_init(), tll_init(), tll_init(), tll_init()},
|
||||
.line_height = { .pt = 0, .px = -1, },
|
||||
|
|
@ -2221,6 +2259,15 @@ config_load(struct config *conf, const char *conf_path,
|
|||
.vertical_letter_offset = {.pt = 0, .px = 0, },
|
||||
.box_drawings_uses_font_glyphs = false,
|
||||
.dpi_aware = DPI_AWARE_AUTO, /* DPI-aware when scaling-factor == 1 */
|
||||
.bell = {
|
||||
.urgent = false,
|
||||
.notify = false,
|
||||
.command = {
|
||||
.raw_cmd = NULL,
|
||||
.argv = NULL,
|
||||
},
|
||||
.command_focused = false,
|
||||
},
|
||||
.scrollback = {
|
||||
.lines = 1000,
|
||||
.indicator = {
|
||||
|
|
@ -2446,6 +2493,7 @@ config_free(struct config conf)
|
|||
free(conf.app_id);
|
||||
free(conf.word_delimiters);
|
||||
free(conf.jump_label_letters);
|
||||
free_spawn_template(&conf.bell.command);
|
||||
free(conf.scrollback.indicator.text);
|
||||
free_spawn_template(&conf.notify);
|
||||
free_spawn_template(&conf.url_launch);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue