Discussion:
[PATCH] Add format for reading session activity
(too old to reply)
Takatoshi Matsumoto
2015-02-27 07:40:07 UTC
Permalink
Hi, this patch adds session_activity and session_activity_string.
With these additions, it's possible to do some operations to sessions by active time from CLI.

e.g. getting last active session
tmux list-sessions -F'#{session_activity} #{session_id} #{session_name}' | tr -d '$' | sort -k 1 -k 2n

---
format.c | 6 ++++++
tmux.1 | 2 ++
2 files changed, 8 insertions(+)

diff --git a/format.c b/format.c
index 776de96..2ef5b84 100644
--- a/format.c
+++ b/format.c
@@ -503,6 +503,12 @@ format_defaults_session(struct format_tree *ft, struct session *s)
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);

+ t = s->activity_time.tv_sec;
+ format_add(ft, "session_activity", "%lld", (long long) t);
+ tim = ctime(&t);
+ *strchr(tim, '\n') = '\0';
+ format_add(ft, "session_activity_string", "%s", tim);
+
format_add(ft, "session_attached", "%u", s->attached);
format_add(ft, "session_many_attached", "%u", s->attached > 1);
}
diff --git a/tmux.1 b/tmux.1
index f615dd0..876dd74 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3153,6 +3153,8 @@ The following variables are available, where appropriate:
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
+.It Li "session_activity" Ta "" Ta "Integer time session last had activity"
+.It Li "session_activity_string" Ta "" Ta "String time session last had activity"
.It Li "session_created" Ta "" Ta "Integer time session created"
.It Li "session_created_string" Ta "" Ta "String time session created"
.It Li "session_group" Ta "" Ta "Number of session group"
--
2.3.0
Nicholas Marriott
2015-03-31 17:58:53 UTC
Permalink
Applied to OpenBSD now, thanks
Post by Takatoshi Matsumoto
Hi, this patch adds session_activity and session_activity_string.
With these additions, it's possible to do some operations to sessions by active time from CLI.
e.g. getting last active session
tmux list-sessions -F'#{session_activity} #{session_id} #{session_name}' | tr -d '$' | sort -k 1 -k 2n
---
format.c | 6 ++++++
tmux.1 | 2 ++
2 files changed, 8 insertions(+)
diff --git a/format.c b/format.c
index 776de96..2ef5b84 100644
--- a/format.c
+++ b/format.c
@@ -503,6 +503,12 @@ format_defaults_session(struct format_tree *ft, struct session *s)
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);
+ t = s->activity_time.tv_sec;
+ format_add(ft, "session_activity", "%lld", (long long) t);
+ tim = ctime(&t);
+ *strchr(tim, '\n') = '\0';
+ format_add(ft, "session_activity_string", "%s", tim);
+
format_add(ft, "session_attached", "%u", s->attached);
format_add(ft, "session_many_attached", "%u", s->attached > 1);
}
diff --git a/tmux.1 b/tmux.1
index f615dd0..876dd74 100644
--- a/tmux.1
+++ b/tmux.1
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
+.It Li "session_activity" Ta "" Ta "Integer time session last had activity"
+.It Li "session_activity_string" Ta "" Ta "String time session last had activity"
.It Li "session_created" Ta "" Ta "Integer time session created"
.It Li "session_created_string" Ta "" Ta "String time session created"
.It Li "session_group" Ta "" Ta "Number of session group"
--
2.3.0
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...