Hi,

I've just subscribed to the list and while digging through the list's
archives, I've seen that this topic is currently being discussed.

I just happen to have implemented a similar feature myself a couple
of days ago. It would be great to have (something like) that in tmux.
This patch (only tested on FreeBSD 8.2-STABLE so far) introduces a
new config option "bell-on-alert" that rings the terminal bell for
all alert types supported by tmux.

If changes to the patch are needed, please let me know.
E.g. I could add further options for individual alert types 
("bell-on-content-alert", "bell-on-activity-alert" etc.),
though that probably is config bloat.

Regards,
Marco
# HG changeset patch
# User Marco Beck <mb...@miamod.de>
# Date 1308390888 -7200
# Node ID 64d47bef68e29ce1672c1a75a815655f7b0fa56b
# Parent  dae3664b7a22ac5bfcc967a44d369e58cf163c9c
New feature: ring terminal bell upon (bell, content...) alert

diff --git a/cmd-set-option.c b/cmd-set-option.c
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -83,6 +83,7 @@
 const struct set_option_entry set_session_option_table[] = {
 	{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
 	{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
+	{ "bell-on-alert", SET_OPTION_FLAG, 0, 0, NULL },
 	{ "buffer-limit", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
 	{ "default-command", SET_OPTION_STRING, 0, 0, NULL },
 	{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
diff --git a/server-window.c b/server-window.c
--- a/server-window.c
+++ b/server-window.c
@@ -29,6 +29,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
@@ -135,6 +136,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")) {
@@ -184,6 +187,8 @@
 	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")) {
@@ -222,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")) {
@@ -236,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.c b/tmux.c
--- a/tmux.c
+++ b/tmux.c
@@ -331,6 +331,7 @@
 	so = &global_s_options;
 	options_set_number(so, "base-index", 0);
 	options_set_number(so, "bell-action", BELL_ANY);
+	options_set_number(so, "bell-on-alert", 0);
 	options_set_number(so, "buffer-limit", 9);
 	options_set_string(so, "default-command", "%s", "");
 	options_set_string(so, "default-path", "%s", "");
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to