Skip to content

Commit a3c4137

Browse files
committed
datetime on statusbar
1 parent aee3bb0 commit a3c4137

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

dwm.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <X11/Xlib.h>
3737
#include <X11/Xproto.h>
3838
#include <X11/Xutil.h>
39+
#include <time.h>
3940
#ifdef XINERAMA
4041
#include <X11/extensions/Xinerama.h>
4142
#endif /* XINERAMA */
@@ -1378,9 +1379,17 @@ run(void)
13781379
XEvent ev;
13791380
/* main event loop */
13801381
XSync(dpy, False);
1381-
while (running && !XNextEvent(dpy, &ev))
1382+
time_t last_up = time(NULL);
1383+
while (running && !XNextEvent(dpy, &ev)){
1384+
time_t now = time(NULL);
1385+
if(now - last_up >= 60) {
1386+
last_up = now;
1387+
updatestatus();
1388+
updatebars();
1389+
}
13821390
if (handler[ev.type])
13831391
handler[ev.type](&ev); /* call handler */
1392+
}
13841393
}
13851394

13861395
void
@@ -2013,8 +2022,8 @@ updatetitle(Client *c)
20132022
void
20142023
updatestatus(void)
20152024
{
2016-
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
2017-
strcpy(stext, "dwm-"VERSION);
2025+
time_t t = time(NULL);
2026+
strftime(stext, 255, "%a, %d.%m.%Y %H:%M", localtime(&t));
20182027
drawbar(selmon);
20192028
}
20202029

0 commit comments

Comments
 (0)