Hi,

i found out that tmux ignores current/any setting of bell-action
when visual-bell is off so i made patch (bell_fix.patch).
(checked on git://git.code.sf.net/p/tmux/tmux-code)

It also makes some other changes - i don't think that use of
winlink_find_by_window(&s->windows, w) is necessary when there is
already wl, but please check whether i didn't miss anything.

I also made bell_script.patch which allows user to make custom
script for bell event. It also works when tmux is detached which
i think is very useful function not only for me.
But i think it would be better to add some options for it.
It would also need some doc/man changes.
And it might be good to add session number to arguments.
I guess there could be some option like bell-script which when
set would run user script defined by value of this option on
bell event.
It might also be better to use some fork() + exec*() instead of
system().


Filip Moc


--- a/server-window.c	2014-02-03 11:06:48.000000000 +0100
+++ b/server-window.c	2014-02-03 11:07:08.000000000 +0100
@@ -76,7 +76,7 @@
 		wl->flags |= WINLINK_BELL;
 	if (s->flags & SESSION_UNATTACHED)
 		return (0);
-	if (s->curw->window == wl->window)
+	if (s->curw->window == w)
 		w->flags &= ~WINDOW_BELL;
 
 	visual = options_get_number(&s->options, "visual-bell");
@@ -87,16 +87,16 @@
 		c = ARRAY_ITEM(&clients, i);
 		if (c == NULL || c->session != s || (c->flags & CLIENT_CONTROL))
 			continue;
+		if ((c->session->curw->window != w) && (action != BELL_ANY))
+			continue;
 		if (!visual) {
 			tty_bell(&c->tty);
 			continue;
 		}
 		if (c->session->curw->window == w)
 			status_message_set(c, "Bell in current window");
-		else if (action == BELL_ANY) {
-			status_message_set(c, "Bell in window %u",
-				winlink_find_by_window(&s->windows, w)->idx);
-		}
+		else
+			status_message_set(c, "Bell in window %u", wl->idx);
 	}
 
 	return (1);
--- b/server-window.c	2014-02-03 11:07:08.000000000 +0100
+++ c/server-window.c	2014-02-03 12:50:19.000000000 +0100
@@ -69,11 +69,19 @@
 	struct window	*w = wl->window;
 	u_int		 i;
 	int		 action, visual;
+	char            *bellcmd;
 
 	if (!(w->flags & WINDOW_BELL) || wl->flags & WINLINK_BELL)
 		return (0);
 	if (s->curw != wl || s->flags & SESSION_UNATTACHED)
 		wl->flags |= WINLINK_BELL;
+
+	xasprintf(&bellcmd, "[ -x ~/.tmux.bell ] && ~/.tmux.bell '%u' '%s'", wl->idx, w->name);
+	if (system(bellcmd)) {
+		/* here could be some error check */
+	}
+	free(bellcmd);
+
 	if (s->flags & SESSION_UNATTACHED)
 		return (0);
 	if (s->curw->window == w)
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to