From 15d20af2a24664b09604f1ec5f121c38f1500c32 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 10 Dec 2020 18:22:48 +0100 Subject: config: add ‘notify’ to possible values for ‘bell’ in foot.ini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `bell=notify`, foot will trigger a desktop notification when it receives a BEL in an unfocused window. --- terminal.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index a626b88d..e9ccbcd0 100644 --- a/terminal.c +++ b/terminal.c @@ -25,6 +25,7 @@ #include "extract.h" #include "grid.h" #include "ime.h" +#include "notify.h" #include "quirks.h" #include "reaper.h" #include "render.h" @@ -1091,7 +1092,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, .eight_bit = true, }, .num_lock_modifier = true, - .bell_is_urgent = conf->bell_is_urgent, + .bell_action_enabled = true, .tab_stops = tll_init(), .wl = wayl, .render = { @@ -1532,6 +1533,8 @@ term_reset(struct terminal *term, bool hard) term->bracketed_paste = false; term->focus_events = false; term->modify_escape_key = false; + term->num_lock_modifier = true; + term->bell_action_enabled = true; term->mouse_tracking = MOUSE_NONE; term->mouse_reporting = MOUSE_NORMAL; term->charsets.selected = 0; @@ -2512,12 +2515,24 @@ term_flash(struct terminal *term, unsigned duration_ms) void term_bell(struct terminal *term) { - if (term->kbd_focus || !term->bell_is_urgent) + if (term->kbd_focus || !term->bell_action_enabled) return; - /* There's no 'urgency' hint in Wayland - we just paint the margins red */ - term->render.urgency = true; - term_damage_margins(term); + switch (term->conf->bell_action) { + case BELL_ACTION_NONE: + break; + + case BELL_ACTION_URGENT: + /* There's no 'urgency' hint in Wayland - we just paint the + * margins red */ + term->render.urgency = true; + term_damage_margins(term); + break; + + case BELL_ACTION_NOTIFY: + notify_notify(term, "Bell", "Bell in terminal"); + break; + } } bool -- cgit v1.3