bell patches

2014-02-04 Thread Filip Moc
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.0 +0100
+++ b/server-window.c	2014-02-03 11:07:08.0 +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.0 +0100
+++ c/server-window.c	2014-02-03 12:50:19.0 +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


Re: bell patches

2014-02-13 Thread Filip Moc
Hi,

> I'm not clear what this bit is supposed to fix, can you give an example?

Problem is when visual-bell is off and bell-action is set to current
- tmux in this case behaves as if bell-action would be set to any.
Action and whether window is current must be checked before call of tty_bell().

Older tmux versions did this right.
I didn't check but i'm almost certain that this problem came with this:
http://sourceforge.net/p/tmux/tmux-code/ci/a401420273490717de3f6fe8f7f0915692be72a3/


As for bell_script.patch - i just didn't know there were already hooks
planned. I don't think anymore this patch would do any good.


Filip Moc


On Wed, Feb 12, 2014 at 08:34:11PM +, Nicholas Marriott wrote:
> Hi
> 
> I think the winlink_find_by_window bits are fine except there are other
> places which also need to be changed.
> 
> > +   if ((c->session->curw->window != w) && (action != BELL_ANY))
> > +   continue;
> 
> I'm not clear what this bit is supposed to fix, can you give an example?
> 
> The other diff is wrong, the server cannot block randomly so you can't
> call system(). You'd need to use the job.c infrastructure. But I don't
> like the idea much anyway.
> 
> 
> 
> On Mon, Feb 03, 2014 at 01:46:10PM +0100, Filip Moc wrote:
> > 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.0 +0100
> > +++ b/server-window.c   2014-02-03 11:07:08.0 +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.0 +0100
> > +++ c/server-window.c   2014-02-03 12:50:19.0 +0100
> > @@ -69,11 +69,19 @@
> > struct window   *w = wl->window;
> > u_inti;
> > 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.bel