Hi there,

I often have a long list of detached screens, and I don't know when I detached from them. I've therefore implemented the "detach-time" feature; the patch is attached.

Before:
```
There are screens on:
        2330147.abc (Detached)
        1728276.def (Detached)
        1957442.ghi (Detached)
```


After:
```
There are screens on:
        2330147.abc (Detached 2026-05-20 12:00:00)
        1728276.def (Detached 2026-05-20 13:00:00)
        1957442.ghi (Detached 2026-05-20 14:00:00)
```

Should I continue pursuing it in this form, or would it be better for compatibility reasons to add a `--time` switch instead?

Possible alternatives would be:
`--detach-time`
`--creation-time`

Best regards,
Tobias
diff --git a/src/socket.c b/src/socket.c
index 16a4cb5..5dc7cea 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -135,6 +135,7 @@ int FindSocket(int *fdp, int *nfoundp, int *notherp, char *match)
 	struct sent {
 		struct sent *next;
 		int mode;
+		time_t mtime;
 		char *name;
 	} *slist, **slisttail, *sent, *nsent;
 
@@ -218,6 +219,7 @@ int FindSocket(int *fdp, int *nfoundp, int *notherp, char *match)
 		sent->next = NULL;
 		sent->name = SaveStr(name);
 		sent->mode = mode;
+		sent->mtime = st.st_mtime;
 		*slisttail = sent;
 		slisttail = &sent->next;
 		nfound++;
@@ -302,15 +304,25 @@ int FindSocket(int *fdp, int *nfoundp, int *notherp, char *match)
 			case 0700:
 				printf("\t%s\t(Attached)\n", sent->name);
 				break;
-			case 0600:
-				printf("\t%s\t(Detached)\n", sent->name);
+			case 0600: {
+				char tbuf[64];
+				struct tm *tm = localtime(&sent->mtime);
+				if (!tm || strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", tm) == 0)
+					strcpy(tbuf, "unknown");
+				printf("\t%s\t(Detached %s)\n", sent->name, tbuf);
 				break;
+			}
 			case 0701:
 				printf("\t%s\t(Multi, attached)\n", sent->name);
 				break;
-			case 0601:
-				printf("\t%s\t(Multi, detached)\n", sent->name);
+			case 0601: {
+				char tbuf[64];
+				struct tm *tm = localtime(&sent->mtime);
+				if (!tm || strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", tm) == 0)
+					strcpy(tbuf, "unknown");
+				printf("\t%s\t(Multi, detached %s)\n", sent->name, tbuf);
 				break;
+			}
 			case -1:
 				/* No trigraphs here! */
 				printf("\t%s\t(Dead ?%c?)\n", sent->name, '?');

Reply via email to