This repository has been archived by the owner on Jan 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
dwm-6.0-centerclock.diff
82 lines (80 loc) · 2.49 KB
/
dwm-6.0-centerclock.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- dwm.c.orig 2013-09-13 20:21:55.181723277 +0200
+++ dwm.c 2013-09-13 20:22:21.241722676 +0200
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <time.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
@@ -70,7 +71,7 @@ enum { NetSupported, NetWMName, NetWMSta
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
+enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkClock,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
typedef union {
@@ -524,7 +525,7 @@ buttonpress(XEvent *e) {
else if(ev->x > selmon->ww - TEXTW(stext))
click = ClkStatusText;
else
- click = ClkWinTitle;
+ click = ClkClock;
}
else if((c = wintoclient(ev->window))) {
focus(c);
@@ -862,7 +863,9 @@ dirtomon(int dir) {
void
drawbar(Monitor *m) {
- int x;
+ int x, clockw;
+ time_t current;
+ char clock[38];
unsigned int i, occ = 0, urg = 0;
XftColor *col;
Client *c;
@@ -897,13 +900,14 @@ drawbar(Monitor *m) {
else
dc.x = m->ww;
if((dc.w = dc.x - x) > bh) {
+ time(¤t);
+ strftime(clock, 38, clock_fmt, localtime(¤t));
+ clockw = TEXTW(clock);
dc.x = x;
- if(m->sel) {
- col = m == selmon ? dc.sel : dc.norm;
- drawtext(m->sel->name, col, False);
- }
- else
- drawtext(NULL, dc.norm, False);
+ drawtext(NULL, dc.norm, False);
+ dc.w = MIN(dc.w, clockw);
+ dc.x = MAX(dc.x, (m->mw / 2) - (clockw / 2));
+ drawtext(clock, dc.sel, False);
}
XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
XSync(dpy, False);
@@ -1447,11 +1451,8 @@ propertynotify(XEvent *e) {
drawbars();
break;
}
- if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
+ if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName])
updatetitle(c);
- if(c == c->mon->sel)
- drawbar(c->mon);
- }
if(ev->atom == netatom[NetWMWindowType])
updatewindowtype(c);
}
@@ -2344,7 +2345,7 @@ main(int argc, char *argv[]) {
die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n");
else if(argc != 1)
die("usage: dwm [-v]\n");
- if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ if(!setlocale(LC_ALL, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if(!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display\n");