diff options
author | Shubham Saini <shubham6405@gmail.com> | 2020-05-18 14:55:32 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2020-05-18 14:55:32 +0000 |
commit | 8c65a77150db1013d5be1eff3711461de21e0da0 (patch) | |
tree | 1d37311dbc7a2cfe15d3028e6727386289e78de1 /dwm/patches/dwm-status2d-20200508-60bb3df.diff | |
parent | 8ea51c85accb4fb955bca4653ed3fb4140bb85e9 (diff) |
finally done
Diffstat (limited to 'dwm/patches/dwm-status2d-20200508-60bb3df.diff')
-rw-r--r-- | dwm/patches/dwm-status2d-20200508-60bb3df.diff | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/dwm/patches/dwm-status2d-20200508-60bb3df.diff b/dwm/patches/dwm-status2d-20200508-60bb3df.diff new file mode 100644 index 0000000..6f353fd --- /dev/null +++ b/dwm/patches/dwm-status2d-20200508-60bb3df.diff | |||
@@ -0,0 +1,180 @@ | |||
1 | From 60bb3dfaf91227eb02e828d74e6f4758b2c56542 Mon Sep 17 00:00:00 2001 | ||
2 | From: cultab <rroarck@gmail.com> | ||
3 | Date: Fri, 8 May 2020 13:56:08 +0300 | ||
4 | Subject: [PATCH] fix status2d to work after ed3ab6 | ||
5 | |||
6 | ed3ab6 changed the name of the variable sw to tw, now the patch won't apply nor work. | ||
7 | This patch updates the variable name to the new one. | ||
8 | --- | ||
9 | dwm.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- | ||
10 | 1 file changed, 114 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/dwm.c b/dwm.c | ||
13 | index 9fd0286..71e18be 100644 | ||
14 | --- a/dwm.c | ||
15 | +++ b/dwm.c | ||
16 | @@ -163,6 +163,7 @@ static void detachstack(Client *c); | ||
17 | static Monitor *dirtomon(int dir); | ||
18 | static void drawbar(Monitor *m); | ||
19 | static void drawbars(void); | ||
20 | +static int drawstatusbar(Monitor *m, int bh, char* text); | ||
21 | static void enternotify(XEvent *e); | ||
22 | static void expose(XEvent *e); | ||
23 | static void focus(Client *c); | ||
24 | @@ -237,7 +238,7 @@ static void zoom(const Arg *arg); | ||
25 | |||
26 | /* variables */ | ||
27 | static const char broken[] = "broken"; | ||
28 | -static char stext[256]; | ||
29 | +static char stext[1024]; | ||
30 | static int screen; | ||
31 | static int sw, sh; /* X display screen geometry width, height */ | ||
32 | static int bh, blw = 0; /* bar geometry */ | ||
33 | @@ -485,7 +486,7 @@ cleanup(void) | ||
34 | cleanupmon(mons); | ||
35 | for (i = 0; i < CurLast; i++) | ||
36 | drw_cur_free(drw, cursor[i]); | ||
37 | - for (i = 0; i < LENGTH(colors); i++) | ||
38 | + for (i = 0; i < LENGTH(colors) + 1; i++) | ||
39 | free(scheme[i]); | ||
40 | XDestroyWindow(dpy, wmcheckwin); | ||
41 | drw_free(drw); | ||
42 | @@ -693,6 +694,114 @@ dirtomon(int dir) | ||
43 | return m; | ||
44 | } | ||
45 | |||
46 | +int | ||
47 | +drawstatusbar(Monitor *m, int bh, char* stext) { | ||
48 | + int ret, i, w, x, len; | ||
49 | + short isCode = 0; | ||
50 | + char *text; | ||
51 | + char *p; | ||
52 | + | ||
53 | + len = strlen(stext) + 1 ; | ||
54 | + if (!(text = (char*) malloc(sizeof(char)*len))) | ||
55 | + die("malloc"); | ||
56 | + p = text; | ||
57 | + memcpy(text, stext, len); | ||
58 | + | ||
59 | + /* compute width of the status text */ | ||
60 | + w = 0; | ||
61 | + i = -1; | ||
62 | + while (text[++i]) { | ||
63 | + if (text[i] == '^') { | ||
64 | + if (!isCode) { | ||
65 | + isCode = 1; | ||
66 | + text[i] = '\0'; | ||
67 | + w += TEXTW(text) - lrpad; | ||
68 | + text[i] = '^'; | ||
69 | + if (text[++i] == 'f') | ||
70 | + w += atoi(text + ++i); | ||
71 | + } else { | ||
72 | + isCode = 0; | ||
73 | + text = text + i + 1; | ||
74 | + i = -1; | ||
75 | + } | ||
76 | + } | ||
77 | + } | ||
78 | + if (!isCode) | ||
79 | + w += TEXTW(text) - lrpad; | ||
80 | + else | ||
81 | + isCode = 0; | ||
82 | + text = p; | ||
83 | + | ||
84 | + w += 2; /* 1px padding on both sides */ | ||
85 | + ret = x = m->ww - w; | ||
86 | + | ||
87 | + drw_setscheme(drw, scheme[LENGTH(colors)]); | ||
88 | + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; | ||
89 | + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; | ||
90 | + drw_rect(drw, x, 0, w, bh, 1, 1); | ||
91 | + x++; | ||
92 | + | ||
93 | + /* process status text */ | ||
94 | + i = -1; | ||
95 | + while (text[++i]) { | ||
96 | + if (text[i] == '^' && !isCode) { | ||
97 | + isCode = 1; | ||
98 | + | ||
99 | + text[i] = '\0'; | ||
100 | + w = TEXTW(text) - lrpad; | ||
101 | + drw_text(drw, x, 0, w, bh, 0, text, 0); | ||
102 | + | ||
103 | + x += w; | ||
104 | + | ||
105 | + /* process code */ | ||
106 | + while (text[++i] != '^') { | ||
107 | + if (text[i] == 'c') { | ||
108 | + char buf[8]; | ||
109 | + memcpy(buf, (char*)text+i+1, 7); | ||
110 | + buf[7] = '\0'; | ||
111 | + drw_clr_create(drw, &drw->scheme[ColFg], buf); | ||
112 | + i += 7; | ||
113 | + } else if (text[i] == 'b') { | ||
114 | + char buf[8]; | ||
115 | + memcpy(buf, (char*)text+i+1, 7); | ||
116 | + buf[7] = '\0'; | ||
117 | + drw_clr_create(drw, &drw->scheme[ColBg], buf); | ||
118 | + i += 7; | ||
119 | + } else if (text[i] == 'd') { | ||
120 | + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; | ||
121 | + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; | ||
122 | + } else if (text[i] == 'r') { | ||
123 | + int rx = atoi(text + ++i); | ||
124 | + while (text[++i] != ','); | ||
125 | + int ry = atoi(text + ++i); | ||
126 | + while (text[++i] != ','); | ||
127 | + int rw = atoi(text + ++i); | ||
128 | + while (text[++i] != ','); | ||
129 | + int rh = atoi(text + ++i); | ||
130 | + | ||
131 | + drw_rect(drw, rx + x, ry, rw, rh, 1, 0); | ||
132 | + } else if (text[i] == 'f') { | ||
133 | + x += atoi(text + ++i); | ||
134 | + } | ||
135 | + } | ||
136 | + | ||
137 | + text = text + i + 1; | ||
138 | + i=-1; | ||
139 | + isCode = 0; | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + if (!isCode) { | ||
144 | + w = TEXTW(text) - lrpad; | ||
145 | + drw_text(drw, x, 0, w, bh, 0, text, 0); | ||
146 | + } | ||
147 | + | ||
148 | + drw_setscheme(drw, scheme[SchemeNorm]); | ||
149 | + free(p); | ||
150 | + | ||
151 | + return ret; | ||
152 | +} | ||
153 | + | ||
154 | void | ||
155 | drawbar(Monitor *m) | ||
156 | { | ||
157 | @@ -704,9 +813,7 @@ drawbar(Monitor *m) | ||
158 | |||
159 | /* draw status first so it can be overdrawn by tags later */ | ||
160 | if (m == selmon) { /* status is only drawn on selected monitor */ | ||
161 | - drw_setscheme(drw, scheme[SchemeNorm]); | ||
162 | - tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ | ||
163 | - drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); | ||
164 | + tw = m->ww - drawstatusbar(m, bh, stext); | ||
165 | } | ||
166 | |||
167 | for (c = m->clients; c; c = c->next) { | ||
168 | @@ -1568,7 +1675,8 @@ setup(void) | ||
169 | cursor[CurResize] = drw_cur_create(drw, XC_sizing); | ||
170 | cursor[CurMove] = drw_cur_create(drw, XC_fleur); | ||
171 | /* init appearance */ | ||
172 | - scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); | ||
173 | + scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); | ||
174 | + scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3); | ||
175 | for (i = 0; i < LENGTH(colors); i++) | ||
176 | scheme[i] = drw_scm_create(drw, colors[i], 3); | ||
177 | /* init bars */ | ||
178 | -- | ||
179 | 2.26.2 | ||
180 | |||