summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-06-15 10:58:01 +0000
committernicm <nicm@openbsd.org>2015-06-15 10:58:01 +0000
commit3ed30b78dc52a2b0b3a9659f740907023b7dddfa (patch)
treeec9d822999c36572a952332002d87f9ee388dca9
parenthook up chmod (diff)
downloadwireguard-openbsd-3ed30b78dc52a2b0b3a9659f740907023b7dddfa.tar.xz
wireguard-openbsd-3ed30b78dc52a2b0b3a9659f740907023b7dddfa.zip
Add window_activity format, from Thomas Adam based on a diff originally
from propos6 at gmail dot com.
-rw-r--r--usr.bin/tmux/format.c7
-rw-r--r--usr.bin/tmux/input.c6
-rw-r--r--usr.bin/tmux/tmux.16
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/window.c5
5 files changed, 21 insertions, 6 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index ee6a5c53874..3dc3e3dc949 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.72 2015/06/14 10:07:44 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.73 2015/06/15 10:58:01 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -749,6 +749,7 @@ void
format_defaults_window(struct format_tree *ft, struct window *w)
{
char *layout;
+ time_t t;
ft->w = w;
@@ -757,6 +758,10 @@ format_defaults_window(struct format_tree *ft, struct window *w)
else
layout = layout_dump(w->layout_root);
+ t = w->activity_time.tv_sec;
+ format_add(ft, "window_activity", "%lld", (long long) t);
+ format_add(ft, "window_activity_string", "%s", format_time_string(t));
+
format_add(ft, "window_id", "@%u", w->id);
format_add(ft, "window_name", "%s", w->name);
format_add(ft, "window_width", "%u", w->sx);
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index e73119fd41b..3bc680667ad 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.78 2015/06/05 22:33:39 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.79 2015/06/15 10:58:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "tmux.h"
@@ -849,6 +850,9 @@ input_parse(struct window_pane *wp)
wp->window->flags |= WINDOW_ACTIVITY;
wp->window->flags &= ~WINDOW_SILENCE;
+ if (gettimeofday(&wp->window->activity_time, NULL) != 0)
+ fatal("gettimeofday failed");
+
/*
* Open the screen. Use NULL wp if there is a mode set as don't want to
* update the tty.
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 8e9c903b797..003d3db810e 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.437 2015/06/14 10:07:44 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.438 2015/06/15 10:58:01 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: June 14 2015 $
+.Dd $Mdocdate: June 15 2015 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -3414,6 +3414,8 @@ The following variables are available, where appropriate:
.It Li "session_name" Ta "#S" Ta "Name of session"
.It Li "session_width" Ta "" Ta "Width of session"
.It Li "session_windows" Ta "" Ta "Number of windows in session"
+.It Li "window_activity" Ta "" Ta "Integer time of window last activity"
+.It Li "window_activity_string" Ta "" Ta "String time of window last activity"
.It Li "window_active" Ta "" Ta "1 if window active"
.It Li "window_activity_flag" Ta "" Ta "1 if window has activity alert"
.It Li "window_bell_flag" Ta "" Ta "1 if window has bell"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index a99b38e4b1b..ce057af9360 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.523 2015/06/14 10:07:44 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.524 2015/06/15 10:58:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -892,6 +892,7 @@ struct window {
char *name;
struct event name_timer;
struct timeval silence_timer;
+ struct timeval activity_time;
struct window_pane *active;
struct window_pane *last;
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 94489e1772c..14f14fea6a9 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.132 2015/06/04 11:43:51 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.133 2015/06/15 10:58:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -295,6 +295,9 @@ window_create1(u_int sx, u_int sy)
w->sx = sx;
w->sy = sy;
+ if (gettimeofday(&w->activity_time, NULL) != 0)
+ fatal("gettimeofday failed");
+
options_init(&w->options, &global_w_options);
if (options_get_number(&w->options, "automatic-rename"))
queue_window_name(w);