Hi,

On Thu, Jun 23, 2011 at 10:56:28AM +0100, Nicholas Marriott wrote:

> This looks okay but the options code has changed for tmux SVN. Can you
> provide a diff against the top of SVN?
> 
> Also please add the option to the man page.

Sure, the patch attached is against SVN trunk.

Thanks,
Marco
# HG changeset patch
# User Marco Beck <mb...@miamod.de>
# Date 1308868029 -7200
# Node ID 75239794e945b99734c3668b654c61ccc2476fd3
# Parent  db675b1c6a76574e0555c917c69fa799882d6e0e
Ring terminal bell on activity, content and silence alerts

diff --git a/options-table.c b/options-table.c
--- a/options-table.c
+++ b/options-table.c
@@ -97,6 +97,11 @@
 	  .default_num = BELL_ANY
 	},
 
+	{ .name = "bell-on-alert",
+	  .type = OPTIONS_TABLE_FLAG,
+	  .default_num = 0
+	},
+
 	{ .name = "default-command",
 	  .type = OPTIONS_TABLE_STRING,
 	  .default_str = ""
diff --git a/server-window.c b/server-window.c
--- a/server-window.c
+++ b/server-window.c
@@ -28,6 +28,7 @@
 int	server_window_check_silence(struct session *, struct winlink *);
 int	server_window_check_content(
 	    struct session *, struct winlink *, struct window_pane *);
+void	ring_bell(struct session *);
 
 /* Window functions that need to happen every loop. */
 void
@@ -134,6 +135,8 @@
 	if (!options_get_number(&w->options, "monitor-activity"))
 		return (0);
 
+	if (options_get_number(&s->options, "bell-on-alert"))
+		ring_bell(s);
 	wl->flags |= WINLINK_ACTIVITY;
 
 	if (options_get_number(&s->options, "visual-activity")) {
@@ -183,6 +186,9 @@
 	timer_difference = timer.tv_sec - w->silence_timer.tv_sec;
 	if (timer_difference <= silence_interval)
 		return (0);
+
+	if (options_get_number(&s->options, "bell-on-alert"))
+		ring_bell(s);
 	wl->flags |= WINLINK_SILENCE;
 
 	if (options_get_number(&s->options, "visual-silence")) {
@@ -221,6 +227,8 @@
 		return (0);
 	xfree(found);
 
+	if (options_get_number(&s->options, "bell-on-alert"))
+		ring_bell(s);
 	wl->flags |= WINLINK_CONTENT;
 
 	if (options_get_number(&s->options, "visual-content")) {
@@ -235,3 +243,18 @@
 
 	return (1);
 }
+
+/* Ring terminal bell */
+void
+ring_bell(struct session *s)
+{
+	struct client *c;
+	u_int i;
+
+	for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+		c = ARRAY_ITEM(&clients, i);
+		if (c == NULL || c->session != s)
+			continue;
+		tty_putcode(&c->tty, TTYC_BEL);
+	}
+}
diff --git a/tmux.1 b/tmux.1
--- a/tmux.1
+++ b/tmux.1
@@ -1766,6 +1766,11 @@
 means all bells are ignored and
 .Ic current
 means only bell in windows other than the current window are ignored.
+.It Xo Ic bell-on-alert
+.Op Ic on | off
+.Xc
+If on, ring the terminal bell when an activity, content or silence alert
+occurs.
 .It Ic default-command Ar shell-command
 Set the command used for new windows (if not specified when the window is
 created) to
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to