diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-12-11 18:44:32 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-12-11 18:44:32 +0000 |
| commit | 934466bc84c007a3935f57079df1036c132c3393 (patch) | |
| tree | 34d9ab652f1c24399f098aafc5b80ad4de9e6016 /config.c | |
| parent | Merge branch 'remove-deprecated-things' (diff) | |
| parent | config: add ‘notify’ to possible values for ‘bell’ in foot.ini (diff) | |
Merge branch 'osc777-notify'
Closes #224
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 44 |
1 files changed, 39 insertions, 5 deletions
@@ -483,14 +483,17 @@ 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_is_urgent = true; + 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_is_urgent = false; + conf->bell_action = BELL_ACTION_NONE; else { LOG_AND_NOTIFY_ERR( "%s:%d: [default]: bell: " - "expected either 'set-urgency' or 'none'", path, lineno); - conf->bell_is_urgent = false; + "expected either 'set-urgency', 'notify' or 'none'", + path, lineno); + conf->bell_action = BELL_ACTION_NONE; return false; } } @@ -566,6 +569,27 @@ parse_section_main(const char *key, const char *value, struct config *conf, mbstowcs(conf->word_delimiters, value, chars + 1); } + else if (strcmp(key, "notify") == 0) { + free(conf->notify.raw_cmd); + free(conf->notify.argv); + + conf->notify.raw_cmd = NULL; + conf->notify.argv = NULL; + + char *raw_cmd = xstrdup(value); + char **argv = NULL; + + if (!tokenize_cmdline(raw_cmd, &argv)) { + LOG_AND_NOTIFY_ERR( + "%s:%d: [default]: notify: syntax error in command line", + path, lineno); + return false; + } + + conf->notify.raw_cmd = raw_cmd; + conf->notify.argv = argv; + } + else { LOG_AND_NOTIFY_ERR("%s:%u: [default]: %s: invalid key", path, lineno, key); return false; @@ -1924,7 +1948,7 @@ config_load(struct config *conf, const char *conf_path, .pad_x = 2, .pad_y = 2, .bold_in_bright = false, - .bell_is_urgent = false, + .bell_action = BELL_ACTION_NONE, .startup_mode = STARTUP_WINDOWED, .fonts = {tll_init(), tll_init(), tll_init(), tll_init()}, .dpi_aware = true, /* Use DPI by default, not scale factor */ @@ -1989,6 +2013,10 @@ config_load(struct config *conf, const char *conf_path, .server_socket_path = get_server_socket_path(), .presentation_timings = false, .hold_at_exit = false, + .notify = { + .raw_cmd = NULL, + .argv = NULL, + }, .tweak = { .fcft_filter = FCFT_SCALING_FILTER_LANCZOS3, @@ -2004,6 +2032,10 @@ config_load(struct config *conf, const char *conf_path, .notifications = tll_init(), }; + conf->notify.raw_cmd = xstrdup( + "notify-send -a foot -i foot ${title} ${body}"); + tokenize_cmdline(conf->notify.raw_cmd, &conf->notify.argv); + tll_foreach(*initial_user_notifications, it) tll_push_back(conf->notifications, it->item); tll_free(*initial_user_notifications); @@ -2070,6 +2102,8 @@ config_free(struct config conf) free(conf.app_id); free(conf.word_delimiters); free(conf.scrollback.indicator.text); + free(conf.notify.raw_cmd); + free(conf.notify.argv); for (size_t i = 0; i < ALEN(conf.fonts); i++) { tll_foreach(conf.fonts[i], it) config_font_destroy(&it->item); |
