Your email client has mangled this diff, please send it again as an attachment.
On Wed, Jul 26, 2017 at 11:58:07AM +0200, Yvain Thonnart wrote: > Hi Nicholas, > Thanks for the feedback. > I tried and went for your second option in the patch below. > 'bell-on-alert' mimics 'bell-action' as much as possible. > In particular, 'bell-on-alert' now notifies all the clients, as for > 'alerts_check_bell' > Nevertheless, I kept the original behaviour of both visual+audible (or > hint), > instead of the if (!visible) in 'alerts_check_bell'. > The patch also fixes a typo in 'alerts_check_bell', for > 'bell-action'=other (ws!=w -> ws==w) > Is that what you had in mind ? > Best regards, > Yvain > From 38a59edc4ed70857e67d88c62d188ecd08515191 Mon Sep 17 00:00:00 2001 > From: Yvain Thonnart <yvain.thonn...@m4x.org> > Date: Wed, 26 Jul 2017 11:14:18 +0200 > Subject: [PATCH] turn bell-on-alert to a choice option > bell-on-alert becomes a choice option like bell-action. > bell-on-alert [any | none | current | other] > A A A A Set action on window alert. A any means an alert in any window > linked > A A A A to a session causes an alert in the current window of that > session, > A A A A none means all alerts are ignored, current means only alerts > in win- > A A A A dows other than the current window are ignored and other means > alerts > A A A A in the current window are ignored but not those in other > windows. > Rationale: > Bell can be used as an urgency hint. > Excluding current window is fine when the actual terminal running tmux is > in the foreground e.g. in a X session, but actually hides the upstream > notification to terminal and window-manager. > Also fixes a typo in alerts_check_bell, for bell-action=other (ws!=w -> > ws==w) > --- > A alerts.c A A A A | 85 > +++++++++++++++++++++++++++++++++++++++++++++------------ > A options-table.c | A 5 ++-- > A tmux.1 A A A A A | 14 ++++++++-- > A 3 files changed, 81 insertions(+), 23 deletions(-) > diff --git a/alerts.c b/alerts.c > index a489d44..9a9f627 100644 > --- a/alerts.c > +++ b/alerts.c > @@ -199,7 +199,7 @@ alerts_check_bell(struct window *w) > A > A if (action == BELL_CURRENT && ws != w) > A action = BELL_NONE; > - if (action == BELL_OTHER && ws != w) > + if (action == BELL_OTHER && ws == w) > A action = BELL_NONE; > A > A if (!visual) { > @@ -222,8 +222,11 @@ alerts_check_bell(struct window *w) > A static int > A alerts_check_activity(struct window *w) > A { > + struct window *ws; > A struct winlink *wl; > A struct session *s; > + struct client *c; > + int action, visual; > A > A if (~w->flags & WINDOW_ACTIVITY) > A return (0); > @@ -237,20 +240,41 @@ alerts_check_activity(struct window *w) > A if (wl->flags & WINLINK_ACTIVITY) > A continue; > A s = wl->session; > - if (s->curw == wl) > - continue; > - > - wl->flags |= WINLINK_ACTIVITY; > - notify_winlink("alert-activity", wl); > + if (s->curw != wl) { > + wl->flags |= WINLINK_ACTIVITY; > + notify_winlink("alert-activity", wl); > + } > A > A if (s->flags & SESSION_ALERTED) > A continue; > A s->flags |= SESSION_ALERTED; > A > - if (options_get_number(s->options, "bell-on-alert")) > - alerts_ring_bell(s); > - if (options_get_number(s->options, "visual-activity")) > - alerts_set_message(s, "Activity in window %d", wl->idx); > + action = options_get_number(s->options, "bell-on-alert"); > + if (action == BELL_NONE) > + return (0); > + > + visual = options_get_number(s->options, "visual-activity"); > + TAILQ_FOREACH(c, &clients, entry) { > + if (c->session != s || c->flags & CLIENT_CONTROL) > + continue; > + ws = c->session->curw->window; > + > + if (action == BELL_CURRENT && ws != w) > + action = BELL_NONE; > + if (action == BELL_OTHER && ws == w) > + action = BELL_NONE; > + > + if (action != BELL_NONE) > + tty_putcode(&c->tty, TTYC_BEL); > + if (visual) { > + if (action == BELL_CURRENT) > + status_message_set(c, "Activity in current window"); > + else if (action != BELL_NONE) { > + status_message_set(c, "Activity in window %d", > + A A wl->idx); > + } > + } > + } > A } > A > A return (WINDOW_ACTIVITY); > @@ -259,8 +283,11 @@ alerts_check_activity(struct window *w) > A static int > A alerts_check_silence(struct window *w) > A { > + struct window *ws; > A struct winlink *wl; > A struct session *s; > + struct client *c; > + int action, visual; > A > A if (~w->flags & WINDOW_SILENCE) > A return (0); > @@ -274,19 +301,41 @@ alerts_check_silence(struct window *w) > A if (wl->flags & WINLINK_SILENCE) > A continue; > A s = wl->session; > - if (s->curw == wl) > - continue; > - wl->flags |= WINLINK_SILENCE; > - notify_winlink("alert-silence", wl); > + if (s->curw != wl) { > + wl->flags |= WINLINK_SILENCE; > + notify_winlink("alert-silence", wl); > + } > A > A if (s->flags & SESSION_ALERTED) > A continue; > A s->flags |= SESSION_ALERTED; > A > - if (options_get_number(s->options, "bell-on-alert")) > - alerts_ring_bell(s); > - if (options_get_number(s->options, "visual-silence")) > - alerts_set_message(s, "Silence in window %d", wl->idx); > + action = options_get_number(s->options, "bell-on-alert"); > + if (action == BELL_NONE) > + return (0); > + > + visual = options_get_number(s->options, "visual-silence"); > + TAILQ_FOREACH(c, &clients, entry) { > + if (c->session != s || c->flags & CLIENT_CONTROL) > + continue; > + ws = c->session->curw->window; > + > + if (action == BELL_CURRENT && ws != w) > + action = BELL_NONE; > + if (action == BELL_OTHER && ws == w) > + action = BELL_NONE; > + > + if (action != BELL_NONE) > + tty_putcode(&c->tty, TTYC_BEL); > + if (visual) { > + if (action == BELL_CURRENT) > + status_message_set(c, "Silence in current window"); > + else if (action != BELL_NONE) { > + status_message_set(c, "Silence in window %d", > + A A wl->idx); > + } > + } > + } > A } > A > A return (WINDOW_SILENCE); > diff --git a/options-table.c b/options-table.c > index 0c0039f..b7bbdcc 100644 > --- a/options-table.c > +++ b/options-table.c > @@ -166,9 +166,10 @@ const struct options_table_entry options_table[] = { > A }, > A > A { .name = "bell-on-alert", > - A .type = OPTIONS_TABLE_FLAG, > + A .type = OPTIONS_TABLE_CHOICE, > A A .scope = OPTIONS_TABLE_SESSION, > - A .default_num = 0 > + A .choices = options_table_bell_action_list, > + A .default_num = BELL_NONE > A }, > A > A { .name = "default-command", > diff --git a/tmux.1 b/tmux.1 > index 09eee74..24acb8e 100644 > --- a/tmux.1 > +++ b/tmux.1 > @@ -2544,10 +2544,18 @@ means only bells in windows other than the current > window are ignored and > A .Ic other > A means bells in the current window are ignored but not those in other > windows. > A .It Xo Ic bell-on-alert > -.Op Ic on | off > +.Op Ic any | none | current | other > A .Xc > -If on, ring the terminal bell when an alert > -occurs. > +Set action on window alert. > +.Ic any > +means an alert in any window linked to a session causes an alert in the > +current window of that session, > +.Ic none > +means all alerts are ignored, > +.Ic current > +means only alerts in windows other than the current window are ignored > and > +.Ic other > +means alerts in the current window are ignored but not those in other > windows. > A .It Ic default-command Ar shell-command > A Set the command used for new windows (if not specified when the window > is > A created) to > --A > 2.7.0.25.gfc10eb5 > 2017-07-26 9:32 GMT+02:00 Nicholas Marriott <nicholas.marri...@gmail.com>: > > Hi > > Thanks - I don't think we should do this for everyone by default, but > you could do a couple of things instead: > > - bell-on-alert could also check bell-action to decide whether to send > A the bell (so bell-action "current" would also affect bell-on-alert); > > - Or bell-on-alert could become a three-state option like bell-action, > A so you set bell-on-alert to "current" to make it work in the current > A window. > > I think the second option would probably be better. In both cases you > would need to change both alerts_check_activity and > alerts_check_silence. > > On Mon, Jul 17, 2017 at 07:53:54PM +0200, Yvain Thonnart wrote: > >A A Dear tmux maintainers, > >A A First of all, many thanks for your impressive continued work on > this great > >A A program. > >A A I stumbled upon an issue with activity monitoring in trying to > setup a new > >A A workflow. > >A A I am using the bell as an urgency hint in most of my console > programs, to > >A A notify my terminal and windowmanager (namely xterm and i3wm) of > important > >A A notices. I have been using it with tmux to pass on a bell signal > for a > >A A long time. > >A A Yet, as I recently tried to use activity monitoring, I found out > that the > >A A alert is sent only when the alterting window is not the current > window. > >A A However, as I am using several terminals and workspaces, the > current > >A A window is not always visible, so I needed to create a dummy > window to > >A A switch to in order to get the notification from the real window. > >A A I tried to play a bit with the options, and even with the hooks > in the > >A A latest versions, with no success. > >A A Diggig in the code, I saw that you filter the alerts from the > current > >A A window. > >A A I propose you a little modification, which actually suits my > needs, where > >A A the bell is passed even in current window. > >A A Apparently your integration strategy is via email patches, so I > will post > >A A it as a followup. > >A A I will be happy to discuss this, whether you think it is relevant > or not, > >A A or if I missed a simple configuration setup... > >A A Best regards,A > >A A Yvain Thonnart > >A A -------------------- > >A A Yvain THONNART (1): > >A A AA alerts: activity/silence bell in current window > >A A A alerts.c | 8 ++++---- > >A A A 1 file changed, 4 insertions(+), 4 deletions(-) > > > >A A -- > >A A You received this message because you are subscribed to the > Google Groups > >A A "tmux-users" group. > >A A To unsubscribe from this group and stop receiving emails from it, > send an > >A A email to tmux-users+unsubscr...@googlegroups.com. > >A A To post to this group, send email to tmux-users@googlegroups.com. > >A A For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "tmux-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+unsubscr...@googlegroups.com. To post to this group, send an email to tmux-users@googlegroups.com. For more options, visit https://groups.google.com/d/optout.