summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/alerts.c25
-rw-r--r--usr.bin/tmux/cmd-find.c18
-rw-r--r--usr.bin/tmux/tmux.114
-rw-r--r--usr.bin/tmux/tmux.h4
4 files changed, 53 insertions, 8 deletions
diff --git a/usr.bin/tmux/alerts.c b/usr.bin/tmux/alerts.c
index d98aef8b5a9..1d01ed8d9a8 100644
--- a/usr.bin/tmux/alerts.c
+++ b/usr.bin/tmux/alerts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alerts.c,v 1.8 2015/12/07 09:47:41 nicm Exp $ */
+/* $OpenBSD: alerts.c,v 1.9 2016/01/16 00:36:53 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,6 +29,7 @@ int alerts_enabled(struct window *, int);
void alerts_callback(int, short, void *);
void alerts_reset(struct window *);
+void alerts_run_hook(struct session *, struct winlink *, int);
int alerts_check_all(struct session *, struct winlink *);
int alerts_check_bell(struct session *, struct winlink *);
int alerts_check_activity(struct session *, struct winlink *);
@@ -55,8 +56,6 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
RB_FOREACH(w, windows, &windows) {
RB_FOREACH(s, sessions, &sessions) {
- if (s->flags & SESSION_UNATTACHED)
- continue;
RB_FOREACH(wl, winlinks, &s->windows) {
if (wl->window != w)
continue;
@@ -73,6 +72,22 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
alerts_fired = 0;
}
+void
+alerts_run_hook(struct session *s, struct winlink *wl, int flags)
+{
+ struct cmd_find_state fs;
+
+ if (cmd_find_from_winlink(&fs, s, wl) != 0)
+ return;
+
+ if (flags & WINDOW_BELL)
+ hooks_run(s->hooks, NULL, &fs, "alert-bell");
+ if (flags & WINDOW_SILENCE)
+ hooks_run(s->hooks, NULL, &fs, "alert-silence");
+ if (flags & WINDOW_ACTIVITY)
+ hooks_run(s->hooks, NULL, &fs, "alert-activity");
+}
+
int
alerts_check_all(struct session *s, struct winlink *wl)
{
@@ -81,8 +96,10 @@ alerts_check_all(struct session *s, struct winlink *wl)
alerts = alerts_check_bell(s, wl);
alerts |= alerts_check_activity(s, wl);
alerts |= alerts_check_silence(s, wl);
- if (alerts != 0)
+ if (alerts != 0) {
+ alerts_run_hook(s, wl, alerts);
server_status_session(s);
+ }
return (alerts);
}
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c
index 220e107024c..7edf66876e5 100644
--- a/usr.bin/tmux/cmd-find.c
+++ b/usr.bin/tmux/cmd-find.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find.c,v 1.28 2015/12/17 23:08:22 nicm Exp $ */
+/* $OpenBSD: cmd-find.c,v 1.29 2016/01/16 00:36:53 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -879,6 +879,22 @@ cmd_find_from_session(struct cmd_find_state *fs, struct session *s)
return (0);
}
+/* Find state from a winlink. */
+int
+cmd_find_from_winlink(struct cmd_find_state *fs, struct session *s,
+ struct winlink *wl)
+{
+ cmd_find_clear_state(fs, NULL, 0);
+
+ fs->s = s;
+ fs->wl = wl;
+ fs->w = wl->window;
+ fs->wp = wl->window->active;
+
+ cmd_find_log_state(__func__, fs);
+ return (0);
+}
+
/* Find state from a window. */
int
cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 91d6fa70bf5..53b1b7e6e17 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.475 2015/12/16 21:50:37 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.476 2016/01/16 00:36:53 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 16 2015 $
+.Dd $Mdocdate: January 16 2016 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -3224,6 +3224,16 @@ Each hook has a
.Em name .
The following hooks are available:
.Bl -tag -width "XXXXXXXXXXXXXXXX"
+.It alert-activity
+Run when a window has activity.
+See
+.Ic monitor-activity .
+.It alert-bell
+Run when a window has received a bell.
+.It alert-silence
+Run when a window has been silent.
+See
+.Ic monitor-silence .
.It client-attached
Run when a client is attached.
.It client-detached
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 1c2af721fa7..f86b2a13f95 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.615 2016/01/15 11:31:47 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.616 2016/01/16 00:36:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1780,6 +1780,8 @@ void cmd_find_copy_state(struct cmd_find_state *,
void cmd_find_log_state(const char *, struct cmd_find_state *);
int cmd_find_from_session(struct cmd_find_state *,
struct session *);
+int cmd_find_from_winlink(struct cmd_find_state *,
+ struct session *, struct winlink *);
int cmd_find_from_window(struct cmd_find_state *, struct window *);
int cmd_find_from_pane(struct cmd_find_state *,
struct window_pane *);