Skip to content

Commit

Permalink
Add session_last_attached time and format, from Sina Siadat.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicm committed Sep 10, 2015
1 parent 67ee995 commit cfabe30
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd-attach-session.c
Expand Up @@ -136,6 +136,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
status_timer_start(c);
notify_attached_session_changed(c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
} else {
Expand Down Expand Up @@ -181,6 +182,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
status_timer_start(c);
notify_attached_session_changed(c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;

Expand Down
1 change: 1 addition & 0 deletions cmd-new-session.c
Expand Up @@ -278,6 +278,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
status_timer_start(c);
notify_attached_session_changed(c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
}
recalculate_sizes();
Expand Down
1 change: 1 addition & 0 deletions cmd-switch-client.c
Expand Up @@ -129,6 +129,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
c->session = s;
status_timer_start(c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);

recalculate_sizes();
server_check_unattached();
Expand Down
7 changes: 7 additions & 0 deletions format.c
Expand Up @@ -872,6 +872,13 @@ format_defaults_session(struct format_tree *ft, struct session *s)
format_add(ft, "session_created", "%lld", (long long) t);
format_add(ft, "session_created_string", "%s", format_time_string(t));

t = s->last_attached_time.tv_sec;
if (t != 0) { /* zero if never attached */
format_add(ft, "session_last_attached", "%lld", (long long) t);
format_add(ft, "session_last_attached_string", "%s",
format_time_string(t));
}

t = s->activity_time.tv_sec;
format_add(ft, "session_activity", "%lld", (long long) t);
format_add(ft, "session_activity_string", "%s", format_time_string(t));
Expand Down
1 change: 1 addition & 0 deletions server-fn.c
Expand Up @@ -422,6 +422,7 @@ server_destroy_session(struct session *s)
status_timer_start(c);
notify_attached_session_changed(c);
session_update_activity(s_new, NULL);
gettimeofday(&s_new->last_attached_time, NULL);
server_redraw_client(c);
}
}
Expand Down
2 changes: 2 additions & 0 deletions tmux.1
Expand Up @@ -3401,6 +3401,8 @@ The following variables are available, where appropriate:
.It Li "session_activity_string" Ta "" Ta "String time of session last 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_last_attached" Ta "" Ta "Integer time session last attached"
.It Li "session_last_attached_string" Ta "" Ta "String time session last attached"
.It Li "session_group" Ta "" Ta "Number of session group"
.It Li "session_grouped" Ta "" Ta "1 if session in a group"
.It Li "session_height" Ta "" Ta "Height of session"
Expand Down
1 change: 1 addition & 0 deletions tmux.h
Expand Up @@ -981,6 +981,7 @@ struct session {
int cwd;

struct timeval creation_time;
struct timeval last_attached_time;
struct timeval activity_time;
struct timeval last_activity_time;

Expand Down

0 comments on commit cfabe30

Please sign in to comment.