mirror of
https://github.com/tmux/tmux.git
synced 2025-01-15 05:09:04 +00:00
Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.
This commit is contained in:
parent
d0adcbc98a
commit
3a4f765a51
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-choose-window.c,v 1.22 2010-06-22 23:26:18 tcunha Exp $ */
|
/* $Id: cmd-choose-window.c,v 1.23 2010-12-06 22:52:20 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -87,6 +87,8 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
flag = '!';
|
flag = '!';
|
||||||
else if (wm->flags & WINLINK_CONTENT)
|
else if (wm->flags & WINLINK_CONTENT)
|
||||||
flag = '+';
|
flag = '+';
|
||||||
|
else if (wm->flags & WINLINK_SILENCE)
|
||||||
|
flag = '~';
|
||||||
else if (wm == s->curw)
|
else if (wm == s->curw)
|
||||||
flag = '*';
|
flag = '*';
|
||||||
else if (wm == TAILQ_FIRST(&s->lastw))
|
else if (wm == TAILQ_FIRST(&s->lastw))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.100 2010-10-09 14:29:32 tcunha Exp $ */
|
/* $Id: cmd-set-option.c,v 1.101 2010-12-06 22:52:20 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -136,6 +136,7 @@ const struct set_option_entry set_session_option_table[] = {
|
|||||||
{ "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
{ "visual-silence", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ NULL, 0, 0, 0, NULL }
|
{ NULL, 0, 0, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ const struct set_option_entry set_window_option_table[] = {
|
|||||||
{ "mode-mouse", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "mode-mouse", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "monitor-content", SET_OPTION_STRING, 0, 0, NULL },
|
{ "monitor-content", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
|
{ "monitor-silence",SET_OPTION_NUMBER, 0, INT_MAX, NULL},
|
||||||
{ "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "synchronize-panes", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "synchronize-panes", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
4
input.c
4
input.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: input.c,v 1.109 2010-04-18 15:11:47 tcunha Exp $ */
|
/* $Id: input.c,v 1.110 2010-12-06 22:52:21 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -681,7 +681,9 @@ input_parse(struct window_pane *wp)
|
|||||||
|
|
||||||
if (EVBUFFER_LENGTH(evb) == 0)
|
if (EVBUFFER_LENGTH(evb) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wp->window->flags |= WINDOW_ACTIVITY;
|
wp->window->flags |= WINDOW_ACTIVITY;
|
||||||
|
wp->window->flags &= ~WINDOW_SILENCE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the screen. Use NULL wp if there is a mode set as don't want to
|
* Open the screen. Use NULL wp if there is a mode set as don't want to
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-window.c,v 1.17 2010-08-11 22:16:03 tcunha Exp $ */
|
/* $Id: server-window.c,v 1.18 2010-12-06 22:52:21 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -26,6 +26,7 @@
|
|||||||
int server_window_backoff(struct window_pane *);
|
int server_window_backoff(struct window_pane *);
|
||||||
int server_window_check_bell(struct session *, struct winlink *);
|
int server_window_check_bell(struct session *, struct winlink *);
|
||||||
int server_window_check_activity(struct session *, struct winlink *);
|
int server_window_check_activity(struct session *, struct winlink *);
|
||||||
|
int server_window_check_silence(struct session *, struct winlink *);
|
||||||
int server_window_check_content(
|
int server_window_check_content(
|
||||||
struct session *, struct winlink *, struct window_pane *);
|
struct session *, struct winlink *, struct window_pane *);
|
||||||
|
|
||||||
@ -53,7 +54,8 @@ server_window_loop(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (server_window_check_bell(s, wl) ||
|
if (server_window_check_bell(s, wl) ||
|
||||||
server_window_check_activity(s, wl))
|
server_window_check_activity(s, wl) ||
|
||||||
|
server_window_check_silence(s, wl))
|
||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry)
|
TAILQ_FOREACH(wp, &w->panes, entry)
|
||||||
server_window_check_content(s, wl, wp);
|
server_window_check_content(s, wl, wp);
|
||||||
@ -151,6 +153,55 @@ server_window_check_activity(struct session *s, struct winlink *wl)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for silence in window. */
|
||||||
|
int
|
||||||
|
server_window_check_silence(struct session *s, struct winlink *wl)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct window *w = wl->window;
|
||||||
|
struct timeval timer;
|
||||||
|
u_int i;
|
||||||
|
int silence_interval, timer_difference;
|
||||||
|
|
||||||
|
if (!(w->flags & WINDOW_SILENCE) || wl->flags & WINLINK_SILENCE)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (s->curw == wl) {
|
||||||
|
/*
|
||||||
|
* Reset the timer for this window if we've focused it. We
|
||||||
|
* don't want the timer tripping as soon as we've switched away
|
||||||
|
* from this window.
|
||||||
|
*/
|
||||||
|
if (gettimeofday(&w->silence_timer, NULL) != 0)
|
||||||
|
fatal("gettimeofday failed.");
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
silence_interval = options_get_number(&w->options, "monitor-silence");
|
||||||
|
if (silence_interval == 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (gettimeofday(&timer, NULL) != 0)
|
||||||
|
fatal("gettimeofday");
|
||||||
|
timer_difference = timer.tv_sec - w->silence_timer.tv_sec;
|
||||||
|
if (timer_difference <= silence_interval)
|
||||||
|
return (0);
|
||||||
|
wl->flags |= WINLINK_SILENCE;
|
||||||
|
|
||||||
|
if (options_get_number(&s->options, "visual-silence")) {
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session != s)
|
||||||
|
continue;
|
||||||
|
status_message_set(c, "Silence in window %u",
|
||||||
|
winlink_find_by_window(&s->windows, w)->idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for content change in window. */
|
/* Check for content change in window. */
|
||||||
int
|
int
|
||||||
server_window_check_content(
|
server_window_check_content(
|
||||||
|
4
status.c
4
status.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: status.c,v 1.149 2010-06-22 23:26:18 tcunha Exp $ */
|
/* $Id: status.c,v 1.150 2010-12-06 22:52:21 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -395,6 +395,8 @@ status_replace1(struct client *c,struct winlink *wl,
|
|||||||
tmp[0] = '!';
|
tmp[0] = '!';
|
||||||
else if (wl->flags & WINLINK_ACTIVITY)
|
else if (wl->flags & WINLINK_ACTIVITY)
|
||||||
tmp[0] = '#';
|
tmp[0] = '#';
|
||||||
|
else if (wl->flags & WINLINK_SILENCE)
|
||||||
|
tmp[0] = '~';
|
||||||
else if (wl == s->curw)
|
else if (wl == s->curw)
|
||||||
tmp[0] = '*';
|
tmp[0] = '*';
|
||||||
else if (wl == TAILQ_FIRST(&s->lastw))
|
else if (wl == TAILQ_FIRST(&s->lastw))
|
||||||
|
19
tmux.1
19
tmux.1
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: tmux.1,v 1.273 2010-12-06 21:59:42 nicm Exp $
|
.\" $Id: tmux.1,v 1.274 2010-12-06 22:52:21 nicm Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
.\"
|
.\"
|
||||||
@ -2053,6 +2053,12 @@ display a message when content is present in a window
|
|||||||
for which the
|
for which the
|
||||||
.Ic monitor-content
|
.Ic monitor-content
|
||||||
window option is enabled.
|
window option is enabled.
|
||||||
|
.It Xo Ic visual-silence
|
||||||
|
.Op Ic on | off
|
||||||
|
.Xc
|
||||||
|
If
|
||||||
|
.Ic monitor-silence
|
||||||
|
is enabled, prints a message after the interval has expired on a given window.
|
||||||
.El
|
.El
|
||||||
.It Xo Ic set-window-option
|
.It Xo Ic set-window-option
|
||||||
.Op Fl agu
|
.Op Fl agu
|
||||||
@ -2175,6 +2181,16 @@ pattern
|
|||||||
.Ar match-string
|
.Ar match-string
|
||||||
appears in the window, it is highlighted in the status line.
|
appears in the window, it is highlighted in the status line.
|
||||||
.Pp
|
.Pp
|
||||||
|
.It Xo Ic monitor-silence
|
||||||
|
.Op Ic interval
|
||||||
|
.Xc
|
||||||
|
Monitor for silence (no activity) in the window within
|
||||||
|
.Ic interval
|
||||||
|
seconds.
|
||||||
|
Windows that have been silent for the interval are highlighted in the
|
||||||
|
status line.
|
||||||
|
An interval of zero disables the monitoring.
|
||||||
|
.Pp
|
||||||
.It Xo Ic remain-on-exit
|
.It Xo Ic remain-on-exit
|
||||||
.Op Ic on | off
|
.Op Ic on | off
|
||||||
.Xc
|
.Xc
|
||||||
@ -2386,6 +2402,7 @@ The flag is one of the following symbols appended to the window name:
|
|||||||
.It Li "#" Ta "Window is monitored and activity has been detected."
|
.It Li "#" Ta "Window is monitored and activity has been detected."
|
||||||
.It Li "!" Ta "A bell has occurred in the window."
|
.It Li "!" Ta "A bell has occurred in the window."
|
||||||
.It Li "+" Ta "Window is monitored for content and it has appeared."
|
.It Li "+" Ta "Window is monitored for content and it has appeared."
|
||||||
|
.It Li "~" Ta "The window has been silent for the monitor-silence interval."
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The # symbol relates to the
|
The # symbol relates to the
|
||||||
|
4
tmux.c
4
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.223 2010-12-06 21:59:42 nicm Exp $ */
|
/* $Id: tmux.c,v 1.224 2010-12-06 22:52:21 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -382,6 +382,7 @@ main(int argc, char **argv)
|
|||||||
options_set_number(so, "visual-activity", 0);
|
options_set_number(so, "visual-activity", 0);
|
||||||
options_set_number(so, "visual-bell", 0);
|
options_set_number(so, "visual-bell", 0);
|
||||||
options_set_number(so, "visual-content", 0);
|
options_set_number(so, "visual-content", 0);
|
||||||
|
options_set_number(so, "visual-silence", 0);
|
||||||
|
|
||||||
keylist = xmalloc(sizeof *keylist);
|
keylist = xmalloc(sizeof *keylist);
|
||||||
ARRAY_INIT(keylist);
|
ARRAY_INIT(keylist);
|
||||||
@ -405,6 +406,7 @@ main(int argc, char **argv)
|
|||||||
options_set_number(wo, "mode-mouse", 0);
|
options_set_number(wo, "mode-mouse", 0);
|
||||||
options_set_number(wo, "monitor-activity", 0);
|
options_set_number(wo, "monitor-activity", 0);
|
||||||
options_set_string(wo, "monitor-content", "%s", "");
|
options_set_string(wo, "monitor-content", "%s", "");
|
||||||
|
options_set_number(wo, "monitor-silence", 0);
|
||||||
options_set_number(wo, "window-status-attr", 0);
|
options_set_number(wo, "window-status-attr", 0);
|
||||||
options_set_number(wo, "window-status-bg", 8);
|
options_set_number(wo, "window-status-bg", 8);
|
||||||
options_set_number(wo, "window-status-current-attr", 0);
|
options_set_number(wo, "window-status-current-attr", 0);
|
||||||
|
8
tmux.h
8
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.584 2010-12-06 21:57:56 nicm Exp $ */
|
/* $Id: tmux.h,v 1.585 2010-12-06 22:52:21 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -828,6 +828,7 @@ TAILQ_HEAD(window_panes, window_pane);
|
|||||||
struct window {
|
struct window {
|
||||||
char *name;
|
char *name;
|
||||||
struct event name_timer;
|
struct event name_timer;
|
||||||
|
struct timeval silence_timer;
|
||||||
|
|
||||||
struct window_pane *active;
|
struct window_pane *active;
|
||||||
struct window_pane *last;
|
struct window_pane *last;
|
||||||
@ -843,6 +844,7 @@ struct window {
|
|||||||
#define WINDOW_BELL 0x1
|
#define WINDOW_BELL 0x1
|
||||||
#define WINDOW_ACTIVITY 0x2
|
#define WINDOW_ACTIVITY 0x2
|
||||||
#define WINDOW_REDRAW 0x4
|
#define WINDOW_REDRAW 0x4
|
||||||
|
#define WINDOW_SILENCE 0x8
|
||||||
|
|
||||||
struct options options;
|
struct options options;
|
||||||
|
|
||||||
@ -863,7 +865,9 @@ struct winlink {
|
|||||||
#define WINLINK_BELL 0x1
|
#define WINLINK_BELL 0x1
|
||||||
#define WINLINK_ACTIVITY 0x2
|
#define WINLINK_ACTIVITY 0x2
|
||||||
#define WINLINK_CONTENT 0x4
|
#define WINLINK_CONTENT 0x4
|
||||||
#define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT)
|
#define WINLINK_SILENCE 0x8
|
||||||
|
#define WINLINK_ALERTFLAGS \
|
||||||
|
(WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
|
||||||
|
|
||||||
RB_ENTRY(winlink) entry;
|
RB_ENTRY(winlink) entry;
|
||||||
TAILQ_ENTRY(winlink) sentry;
|
TAILQ_ENTRY(winlink) sentry;
|
||||||
|
10
window.c
10
window.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: window.c,v 1.141 2010-12-06 21:53:50 nicm Exp $ */
|
/* $Id: window.c,v 1.142 2010-12-06 22:52:21 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -636,6 +636,14 @@ window_pane_read_callback(unused struct bufferevent *bufev, void *data)
|
|||||||
input_parse(wp);
|
input_parse(wp);
|
||||||
|
|
||||||
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
|
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we get here, we're not outputting anymore, so set the silence
|
||||||
|
* flag on the window.
|
||||||
|
*/
|
||||||
|
wp->window->flags |= WINDOW_SILENCE;
|
||||||
|
if (gettimeofday(&wp->window->silence_timer, NULL) != 0)
|
||||||
|
fatal("gettimeofday failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
Loading…
Reference in New Issue
Block a user