summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alerts.c23
-rw-r--r--cmd-find.c16
-rw-r--r--tmux.110
-rw-r--r--tmux.h2
4 files changed, 48 insertions, 3 deletions
diff --git a/alerts.c b/alerts.c
index 536ea750..d1fb0fce 100644
--- a/alerts.c
+++ b/alerts.c
@@ -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/cmd-find.c b/cmd-find.c
index 0e85152a..ff795427 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -878,6 +878,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/tmux.1 b/tmux.1
index f3c8066d..87b4a6f4 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3228,6 +3228,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/tmux.h b/tmux.h
index a2e7b450..20e04097 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1782,6 +1782,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 *);