Merge branch 'notify-focus-inhibit'

This commit is contained in:
Daniel Eklöf 2021-10-07 19:42:06 +02:00
commit 3d1fa4bcc3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 27 additions and 8 deletions

View file

@ -34,6 +34,11 @@
## Unreleased ## Unreleased
### Added ### Added
* `notify-focus-inhibit` boolean option, which can be used to control whether
desktop notifications should be inhibited when the terminal has keyboard
focus
### Changed ### Changed
### Deprecated ### Deprecated
### Removed ### Removed

View file

@ -1012,6 +1012,10 @@ parse_section_main(const char *key, const char *value, struct config *conf,
} }
} }
else if (strcmp(key, "notify-focus-inhibit") == 0) {
conf->notify_focus_inhibit = str_to_bool(value);
}
else if (strcmp(key, "url-launch") == 0) { else if (strcmp(key, "url-launch") == 0) {
deprecated_url_option( deprecated_url_option(
conf, "url-launch", "launch", path, lineno); conf, "url-launch", "launch", path, lineno);
@ -2956,6 +2960,7 @@ config_load(struct config *conf, const char *conf_path,
.notify = { .notify = {
.argv = {.args = NULL}, .argv = {.args = NULL},
}, },
.notify_focus_inhibit = true,
.tweak = { .tweak = {
.fcft_filter = FCFT_SCALING_FILTER_LANCZOS3, .fcft_filter = FCFT_SCALING_FILTER_LANCZOS3,

View file

@ -238,6 +238,7 @@ struct config {
} selection_target; } selection_target;
struct config_spawn_template notify; struct config_spawn_template notify;
bool notify_focus_inhibit;
struct { struct {
enum fcft_scaling_filter fcft_filter; enum fcft_scaling_filter fcft_filter;

View file

@ -279,11 +279,17 @@ in this order:
- OSC 777: *\\e]777;notify;<title>;<body>\\e\\\\* - OSC 777: *\\e]777;notify;<title>;<body>\\e\\\\*
Notifications are *inhibited* if the foot window has keyboard By default, notifications are *inhibited* if the foot window
focus. has keyboard focus. See _notify-focus-inhibit_.
Default: _notify-send -a ${app-id} -i ${app-id} ${title} ${body}_. Default: _notify-send -a ${app-id} -i ${app-id} ${title} ${body}_.
*notify-focus-inhibit*
Boolean. If enabled, foot will not display notifications if the
terminal window has keyboard focus.
Default: _yes_
*selection-target* *selection-target*
Clipboard target to automatically copy selected text to. One of Clipboard target to automatically copy selected text to. One of
*none*, *primary*, *clipboard* or *both*. Default: _primary_. *none*, *primary*, *clipboard* or *both*. Default: _primary_.
@ -316,8 +322,10 @@ in this order:
*notify* *notify*
When set to _yes_, foot will emit a desktop notification using When set to _yes_, foot will emit a desktop notification using
the command specified in the *notify* option whenever *BEL* is the command specified in the *notify* option whenever *BEL* is
received and the window does *not* have keyboard focus. Default: received. By default, bell notifications are shown only when the
_no_ window does *not* have keyboard focus. See _notify-focus-inhibit_.
Default: _no_
*command* *command*
When set, foot will execute this command when *BEL* is received. When set, foot will execute this command when *BEL* is received.

View file

@ -19,7 +19,7 @@ notify_notify(const struct terminal *term, const char *title, const char *body)
{ {
LOG_DBG("notify: title=\"%s\", msg=\"%s\"", title, body); LOG_DBG("notify: title=\"%s\", msg=\"%s\"", title, body);
if (term->kbd_focus) { if (term->conf->notify_focus_inhibit && term->kbd_focus) {
/* No notifications while were focused */ /* No notifications while were focused */
return; return;
} }

View file

@ -3081,11 +3081,11 @@ term_bell(struct terminal *term)
term_damage_margins(term); term_damage_margins(term);
} }
} }
if (term->conf->bell.notify)
notify_notify(term, "Bell", "Bell in terminal");
} }
if (term->conf->bell.notify)
notify_notify(term, "Bell", "Bell in terminal");
if ((term->conf->bell.command.argv.args != NULL) && if ((term->conf->bell.command.argv.args != NULL) &&
(!term->kbd_focus || term->conf->bell.command_focused)) (!term->kbd_focus || term->conf->bell.command_focused))
{ {