Sorry, missed the two important lines from the bash prompt: in .tmux.conf: ----------------- set -g activity-action other set -g silence-action current set -g visual-activity on set -g visual-silence on
at bash prompt within tmux: ------------------------------------ tmux setw monitor-silence 10 tmux setw monitor-activity on while true; do echo hello; sleep 1 ; done hello hello [...] hello [Silence in window 0] 2017-07-26 17:00 GMT+02:00 Yvain Thonnart <[email protected]>: > Thank you. > > I've been testing this patch for different configurations, it's very > flexible. > > It runs fine on my side in all reasonable configurations. > I'd be glad that you would merge it to master someday… > > To be thorough, though, I've found a configuration which is totally > unreasonable, but which reports invalid alerts: > > in .tmux.conf: > ----------------- > set -g activity-action other > set -g silence-action current > set -g visual-activity on > set -g visual-silence on > > at bash prompt within tmux: > ------------------------------------ > while true; do echo hello; sleep 1 ; done > hello > hello > [...] > hello > [Silence in window 0] > > It is the combination of both monitor-silence and monitor-activity which > apparently resets the alert timer due to activity, which then fires after > 10 seconds, falsely reporting silence. > > I haven't managed to get the whole callback flow in your code to give you > more clues. > I attached the server log in case this matters to you. > > I guess somebody at least as retort as myself might bump on this if using > this in his/her .tmux.conf: > set -g activity-action other > set -g silence-action current > set -g visual-activity on > set -g visual-silence on > set -g monitor-silence 10 > set -g monitor-activity on > Hoping that the filter on activity->other and silence->current will hide > the events set by default on any window. > > Yet as this configuration is unreasonable, this may not need to be fixed... > > Thanks again for this, and for all your impressive work on this program, > Best regards, > > Yvain > > > 2017-07-26 14:43 GMT+02:00 Nicholas Marriott <[email protected]> > : > >> Hi >> >> OK the problem with making it work exactly like bell-action is that >> bell-action "none" suppresses visual bell as well - this means that if >> the default for bell-on-alert is "none" then anyone who currently uses >> monitor-activity will need to add the option which is not ideal. >> >> Also it means bell-on-alert no longer serves its original purpose of >> allowing both visual and bell for activity and silence. >> >> And bell-on-alert is not a good name for it now. >> >> So here is what I suggest: >> >> - We remove bell-on-alert entirely. >> >> - Instead we add activity-action and silence-action which are equivalent >> to bell-action but can default to "other" instead of "any". >> >> - We add a new value to visual-* "both" so it is still possible to get a >> bell and a message. >> >> This way all three are consistent. >> >> I don't much like adding a new option but it is less confusing. >> >> Please try this: >> >> >> Index: alerts.c >> =================================================================== >> RCS file: /cvs/src/usr.bin/tmux/alerts.c,v >> retrieving revision 1.20 >> diff -u -p -r1.20 alerts.c >> --- alerts.c 28 Jun 2017 06:45:31 -0000 1.20 >> +++ alerts.c 26 Jul 2017 12:42:57 -0000 >> @@ -34,9 +34,8 @@ static int alerts_check_all(struct windo >> static int alerts_check_bell(struct window *); >> static int alerts_check_activity(struct window *); >> static int alerts_check_silence(struct window *); >> -static void printflike(2, 3) alerts_set_message(struct session *, const >> char *, >> - ...); >> -static void alerts_ring_bell(struct session *); >> +static void alerts_set_message(struct session *, struct window *, >> + struct winlink *, const char *, int, int); >> >> static TAILQ_HEAD(, window) alerts_list = TAILQ_HEAD_INITIALIZER(alerts_ >> list); >> >> @@ -162,11 +161,8 @@ alerts_queue(struct window *w, int flags >> static int >> alerts_check_bell(struct window *w) >> { >> - struct window *ws; >> struct winlink *wl; >> struct session *s; >> - struct client *c; >> - int action, visual; >> >> if (~w->flags & WINDOW_BELL) >> return (0); >> @@ -187,33 +183,9 @@ alerts_check_bell(struct window *w) >> continue; >> s->flags |= SESSION_ALERTED; >> >> - action = options_get_number(s->options, "bell-action"); >> - if (action == BELL_NONE) >> - return (0); >> - >> - visual = options_get_number(s->options, "visual-bell"); >> - 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 (!visual) { >> - if (action != BELL_NONE) >> - tty_putcode(&c->tty, TTYC_BEL); >> - continue; >> - } >> - if (action == BELL_CURRENT) >> - status_message_set(c, "Bell in current >> window"); >> - else if (action != BELL_NONE) { >> - status_message_set(c, "Bell in window %d", >> - wl->idx); >> - } >> - } >> + alerts_set_message(s, w, wl, "Bell", >> + options_get_number(s->options, "bell-action"), >> + options_get_number(s->options, "visual-bell")); >> } >> >> return (WINDOW_BELL); >> @@ -237,20 +209,18 @@ alerts_check_activity(struct window *w) >> if (wl->flags & WINLINK_ACTIVITY) >> continue; >> 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); >> + } >> >> if (s->flags & SESSION_ALERTED) >> continue; >> s->flags |= SESSION_ALERTED; >> >> - 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); >> + alerts_set_message(s, w, wl, "Activity", >> + options_get_number(s->options, "activity-action"), >> + options_get_number(s->options, "visual-activity")); >> } >> >> return (WINDOW_ACTIVITY); >> @@ -264,7 +234,7 @@ alerts_check_silence(struct window *w) >> >> if (~w->flags & WINDOW_SILENCE) >> return (0); >> - if (!options_get_number(w->options, "monitor-silence")) >> + if (options_get_number(w->options, "monitor-silence") == 0) >> return (0); >> >> TAILQ_FOREACH(wl, &w->winlinks, wentry) >> @@ -274,50 +244,66 @@ alerts_check_silence(struct window *w) >> if (wl->flags & WINLINK_SILENCE) >> continue; >> 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); >> + } >> >> if (s->flags & SESSION_ALERTED) >> continue; >> s->flags |= SESSION_ALERTED; >> >> - 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); >> + alerts_set_message(s, w, wl, "Silence", >> + options_get_number(s->options, "silence-action"), >> + options_get_number(s->options, "visual-silence")); >> } >> >> return (WINDOW_SILENCE); >> } >> >> static void >> -alerts_set_message(struct session *s, const char *fmt, ...) >> +alerts_set_message(struct session *s, struct window *w, struct winlink >> *wl, >> + const char *type, int action, int visual) >> { >> struct client *c; >> - va_list ap; >> - char *message; >> + int flag; >> >> - va_start(ap, fmt); >> - xvasprintf(&message, fmt, ap); >> - va_end(ap); >> + /* >> + * We have found an alert (bell, activity or silence), so we need >> + * to notify the user. For each client attached to this session, >> + * decide whether a bell (or visual message) is needed. >> + * >> + * {bell,activity,silence}-action determines when we notify: none >> means >> + * nothing happens, current means we only do something for the >> current >> + * window and other means only for windows other than the current. >> + * >> + * If visual-{bell,activity,silence} is on, then a message is >> + * substituted for a bell; if it is off, a bell is sent as >> normal; both >> + * mean both a bell and visual message is sent. >> + */ >> >> + if (action == BELL_NONE) >> + return; >> TAILQ_FOREACH(c, &clients, entry) { >> - if (c->session == s) >> - status_message_set(c, "%s", message); >> - } >> - >> - free(message); >> -} >> - >> -static void >> -alerts_ring_bell(struct session *s) >> -{ >> - struct client *c; >> + if (c->session != s || c->flags & CLIENT_CONTROL) >> + continue; >> + flag = 0; >> + if (action == BELL_ANY) >> + flag = 1; >> + else if (action == BELL_CURRENT) >> + flag = (c->session->curw->window == w); >> + else if (action == BELL_OTHER) >> + flag = (c->session->curw->window != w); >> + if (!flag) >> + continue; >> >> - TAILQ_FOREACH(c, &clients, entry) { >> - if (c->session == s && !(c->flags & CLIENT_CONTROL)) >> + if (visual == VISUAL_OFF || visual == VISUAL_BOTH) >> tty_putcode(&c->tty, TTYC_BEL); >> + if (visual == VISUAL_OFF) >> + continue; >> + if (c->session->curw->window == w) >> + status_message_set(c, "%s in current window", >> type); >> + else >> + status_message_set(c, "%s in window %d", type, >> wl->idx); >> } >> } >> Index: options-table.c >> =================================================================== >> RCS file: /cvs/src/usr.bin/tmux/options-table.c,v >> retrieving revision 1.90 >> diff -u -p -r1.90 options-table.c >> --- options-table.c 23 Jun 2017 15:36:52 -0000 1.90 >> +++ options-table.c 26 Jul 2017 12:42:57 -0000 >> @@ -51,6 +51,9 @@ static const char *options_table_status_ >> static const char *options_table_bell_action_list[] = { >> "none", "any", "current", "other", NULL >> }; >> +static const char *options_table_visual_bell_list[] = { >> + "off", "on", "both", NULL >> +}; >> static const char *options_table_pane_status_list[] = { >> "off", "top", "bottom", NULL >> }; >> @@ -143,6 +146,13 @@ const struct options_table_entry options >> .separator = "," >> }, >> >> + { .name = "activity-action", >> + .type = OPTIONS_TABLE_CHOICE, >> + .scope = OPTIONS_TABLE_SESSION, >> + .choices = options_table_bell_action_list, >> + .default_num = BELL_OTHER >> + }, >> + >> { .name = "assume-paste-time", >> .type = OPTIONS_TABLE_NUMBER, >> .scope = OPTIONS_TABLE_SESSION, >> @@ -166,12 +176,6 @@ const struct options_table_entry options >> .default_num = BELL_ANY >> }, >> >> - { .name = "bell-on-alert", >> - .type = OPTIONS_TABLE_FLAG, >> - .scope = OPTIONS_TABLE_SESSION, >> - .default_num = 0 >> - }, >> - >> { .name = "default-command", >> .type = OPTIONS_TABLE_STRING, >> .scope = OPTIONS_TABLE_SESSION, >> @@ -350,6 +354,13 @@ const struct options_table_entry options >> .default_str = "#S:#I:#W - \"#T\" #{session_alerts}" >> }, >> >> + { .name = "silence-action", >> + .type = OPTIONS_TABLE_CHOICE, >> + .scope = OPTIONS_TABLE_SESSION, >> + .choices = options_table_bell_action_list, >> + .default_num = BELL_OTHER >> + }, >> + >> { .name = "status", >> .type = OPTIONS_TABLE_FLAG, >> .scope = OPTIONS_TABLE_SESSION, >> @@ -502,21 +513,24 @@ const struct options_table_entry options >> }, >> >> { .name = "visual-activity", >> - .type = OPTIONS_TABLE_FLAG, >> + .type = OPTIONS_TABLE_CHOICE, >> .scope = OPTIONS_TABLE_SESSION, >> - .default_num = 0 >> + .choices = options_table_visual_bell_list, >> + .default_num = VISUAL_OFF >> }, >> >> { .name = "visual-bell", >> - .type = OPTIONS_TABLE_FLAG, >> + .type = OPTIONS_TABLE_CHOICE, >> .scope = OPTIONS_TABLE_SESSION, >> - .default_num = 0 >> + .choices = options_table_visual_bell_list, >> + .default_num = VISUAL_OFF >> }, >> >> { .name = "visual-silence", >> - .type = OPTIONS_TABLE_FLAG, >> + .type = OPTIONS_TABLE_CHOICE, >> .scope = OPTIONS_TABLE_SESSION, >> - .default_num = 0 >> + .choices = options_table_visual_bell_list, >> + .default_num = VISUAL_OFF >> }, >> >> { .name = "word-separators", >> Index: tmux.1 >> =================================================================== >> RCS file: /cvs/src/usr.bin/tmux/tmux.1,v >> retrieving revision 1.568 >> diff -u -p -r1.568 tmux.1 >> --- tmux.1 21 Jul 2017 09:17:19 -0000 1.568 >> +++ tmux.1 26 Jul 2017 12:42:58 -0000 >> @@ -2515,6 +2515,25 @@ before interpretation. >> .Pp >> Available session options are: >> .Bl -tag -width Ds >> +.It Xo Ic activity-action >> +.Op Ic any | none | current | other >> +.Xc >> +Set action on window activity when >> +.Ic monitor-activity >> +is on. >> +.Ic any >> +means activity in any window linked to a session causes a bell or message >> +(depending on >> +.Ic visual-activity ) >> +in the current window of that session, >> +.Ic none >> +means all activity is ignored (equivalent to >> +.Ic monitor-activity >> +being off), >> +.Ic current >> +means only activity in windows other than the current window are ignored >> and >> +.Ic other >> +means activity in the current window is ignored but not those in other >> windows. >> .It Ic assume-paste-time Ar milliseconds >> If keys are entered faster than one in >> .Ar milliseconds , >> @@ -2530,20 +2549,8 @@ The default is zero. >> .Op Ic any | none | current | other >> .Xc >> Set action on window bell. >> -.Ic any >> -means a bell in any window linked to a session causes a bell in the >> current >> -window of that session, >> -.Ic none >> -means all bells are ignored, >> -.Ic current >> -means only bells in windows other than the current window are ignored and >> -.Ic other >> -means bells in the current window are ignored but not those in other >> windows. >> -.It Xo Ic bell-on-alert >> -.Op Ic on | off >> -.Xc >> -If on, ring the terminal bell when an alert >> -occurs. >> +The values are the same as those for >> +.Ic activity-action . >> .It Ic default-command Ar shell-command >> Set the command used for new windows (if not specified when the window is >> created) to >> @@ -2759,6 +2766,15 @@ is on. >> Formats are expanded, see the >> .Sx FORMATS >> section. >> +.It Xo Ic silence-action >> +.Op Ic any | none | current | other >> +.Xc >> +Set action on window silence when >> +.Ic monitor-silence >> +is on. >> +The values are the same as those for >> +.Ic activity-action . >> +.Pp >> .It Xo Ic status >> .Op Ic on | off >> .Xc >> @@ -2884,26 +2900,30 @@ set -s user-keys[0] '\e[5;30012~' >> bind User0 resize-pane -L 3 >> .Ed >> .It Xo Ic visual-activity >> -.Op Ic on | off >> +.Op Ic on | off | both >> .Xc >> -If on, display a status line message when activity occurs in a window >> -for which the >> +If on, display a message instead of sending a bell when activity occurs >> in a >> +window for which the >> .Ic monitor-activity >> window option is enabled. >> +If set to both, a bell and a message are produced. >> .It Xo Ic visual-bell >> -.Op Ic on | off >> +.Op Ic on | off | both >> .Xc >> -If this option is on, a message is shown on a bell instead of it being >> passed >> -through to the terminal (which normally makes a sound). >> +If on, a message is shown on a bell instead of it being passed through >> to the >> +terminal (which normally makes a sound). >> +If set to both, a bell and a message are produced. >> Also see the >> .Ic bell-action >> option. >> .It Xo Ic visual-silence >> -.Op Ic on | off >> +.Op Ic on | off | both >> .Xc >> If >> .Ic monitor-silence >> -is enabled, prints a message after the interval has expired on a given >> window. >> +is enabled, prints a message after the interval has expired on a given >> window >> +instead of sending a bell. >> +If set to both, a bell and a message are produced. >> .It Ic word-separators Ar string >> Sets the session's conception of what characters are considered word >> separators, for the purposes of the next and previous word commands in >> Index: tmux.h >> =================================================================== >> RCS file: /cvs/src/usr.bin/tmux/tmux.h,v >> retrieving revision 1.796 >> diff -u -p -r1.796 tmux.h >> --- tmux.h 14 Jul 2017 18:49:07 -0000 1.796 >> +++ tmux.h 26 Jul 2017 12:42:58 -0000 >> @@ -83,6 +83,11 @@ struct tmuxproc; >> #define BELL_CURRENT 2 >> #define BELL_OTHER 3 >> >> +/* Visual option values. */ >> +#define VISUAL_OFF 0 >> +#define VISUAL_ON 1 >> +#define VISUAL_BOTH 2 >> + >> /* Special key codes. */ >> #define KEYC_NONE 0xffff00000000ULL >> #define KEYC_UNKNOWN 0xfffe00000000ULL >> > > -- 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 [email protected]. To post to this group, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
