Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

340 lines
12 KiB

4 years ago
  1. diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
  2. --- dwm-6.2-ori/config.def.h 2019-02-02 18:25:28.000000000 +0530
  3. +++ dwm-6.2/config.def.h 2020-07-30 00:13:59.458409207 +0530
  4. @@ -12,10 +12,34 @@
  5. static const char col_gray3[] = "#bbbbbb";
  6. static const char col_gray4[] = "#eeeeee";
  7. static const char col_cyan[] = "#005577";
  8. +static const char col1[] = "#ffffff";
  9. +static const char col2[] = "#ffffff";
  10. +static const char col3[] = "#ffffff";
  11. +static const char col4[] = "#ffffff";
  12. +static const char col5[] = "#ffffff";
  13. +static const char col6[] = "#ffffff";
  14. +static const char col7[] = "#ffffff";
  15. +static const char col8[] = "#ffffff";
  16. +static const char col9[] = "#ffffff";
  17. +static const char col10[] = "#ffffff";
  18. +static const char col11[] = "#ffffff";
  19. +static const char col12[] = "#ffffff";
  20. static const char *colors[][3] = {
  21. /* fg bg border */
  22. - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
  23. - [SchemeSel] = { col_gray4, col_cyan, col_cyan },
  24. + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
  25. + [SchemeSel] = { col_gray4, col_cyan, col_cyan },
  26. + [SchemeCol1] = { col1, col_gray1, col_gray2 },
  27. + [SchemeCol2] = { col2, col_gray1, col_gray2 },
  28. + [SchemeCol3] = { col3, col_gray1, col_gray2 },
  29. + [SchemeCol4] = { col4, col_gray1, col_gray2 },
  30. + [SchemeCol5] = { col5, col_gray1, col_gray2 },
  31. + [SchemeCol6] = { col6, col_gray1, col_gray2 },
  32. + [SchemeCol7] = { col7, col_gray1, col_gray2 },
  33. + [SchemeCol8] = { col8, col_gray1, col_gray2 },
  34. + [SchemeCol9] = { col8, col_gray1, col_gray2 },
  35. + [SchemeCol10] = { col10, col_gray1, col_gray2 },
  36. + [SchemeCol11] = { col11, col_gray1, col_gray2 },
  37. + [SchemeCol12] = { col12, col_gray1, col_gray2 },
  38. };
  39. /* tagging */
  40. @@ -103,7 +127,9 @@
  41. { ClkLtSymbol, 0, Button1, setlayout, {0} },
  42. { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
  43. { ClkWinTitle, 0, Button2, zoom, {0} },
  44. - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
  45. + { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
  46. + { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
  47. + { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
  48. { ClkClientWin, MODKEY, Button1, movemouse, {0} },
  49. { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
  50. { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
  51. diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
  52. --- dwm-6.2-ori/dwm.c 2019-02-02 18:25:28.000000000 +0530
  53. +++ dwm-6.2/dwm.c 2020-07-30 00:22:43.991855443 +0530
  54. @@ -40,6 +40,8 @@
  55. #include <X11/extensions/Xinerama.h>
  56. #endif /* XINERAMA */
  57. #include <X11/Xft/Xft.h>
  58. +#include <fcntl.h>
  59. +#include <sys/prctl.h>
  60. #include "drw.h"
  61. #include "util.h"
  62. @@ -56,10 +58,15 @@
  63. #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
  64. #define TAGMASK ((1 << LENGTH(tags)) - 1)
  65. #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
  66. +#define TTEXTW(X) drw_fontset_getwidth(drw, (X))
  67. +
  68. +#define DWMBLOCKSLOCKFILE "/tmp/dwmblocks.pid"
  69. /* enums */
  70. -enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
  71. -enum { SchemeNorm, SchemeSel }; /* color schemes */
  72. +enum { CurNormal, CurHand, CurResize, CurMove, CurLast }; /* cursor */
  73. +enum { SchemeNorm, SchemeSel, SchemeCol1, SchemeCol2, SchemeCol3,
  74. + SchemeCol4, SchemeCol5, SchemeCol6, SchemeCol7, SchemeCol8,
  75. + SchemeCol9, SchemeCol10, SchemeCol11, SchemeCol12 }; /* color schemes */
  76. enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
  77. NetWMFullscreen, NetActiveWindow, NetWMWindowType,
  78. NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
  79. @@ -205,6 +212,7 @@
  80. static void seturgent(Client *c, int urg);
  81. static void showhide(Client *c);
  82. static void sigchld(int unused);
  83. +static void sigdwmblocks(const Arg *arg);
  84. static void spawn(const Arg *arg);
  85. static void tag(const Arg *arg);
  86. static void tagmon(const Arg *arg);
  87. @@ -216,9 +224,11 @@
  88. static void unfocus(Client *c, int setfocus);
  89. static void unmanage(Client *c, int destroyed);
  90. static void unmapnotify(XEvent *e);
  91. +static void updatebarcursor(int cursorpos);
  92. static void updatebarpos(Monitor *m);
  93. static void updatebars(void);
  94. static void updateclientlist(void);
  95. +static void updatedwmblockssig(int x, int e);
  96. static int updategeom(void);
  97. static void updatenumlockmask(void);
  98. static void updatesizehints(Client *c);
  99. @@ -236,7 +246,10 @@
  100. /* variables */
  101. static const char broken[] = "broken";
  102. -static char stext[256];
  103. +static char stextc[256];
  104. +static char stexts[256];
  105. +static int wstext;
  106. +static int dwmblockssig;
  107. static int screen;
  108. static int sw, sh; /* X display screen geometry width, height */
  109. static int bh, blw = 0; /* bar geometry */
  110. @@ -439,10 +452,14 @@
  111. arg.ui = 1 << i;
  112. } else if (ev->x < x + blw)
  113. click = ClkLtSymbol;
  114. - else if (ev->x > selmon->ww - TEXTW(stext))
  115. - click = ClkStatusText;
  116. - else
  117. - click = ClkWinTitle;
  118. + else if (ev->x < selmon->ww - wstext)
  119. + click = ClkWinTitle;
  120. +// else if (ev->x < selmon->ww - lrpad / 2 && ev->x >= (x = selmon->ww - wstext + lrpad / 2)) {
  121. + else if (ev->x < selmon->ww - lrpad / 2 && ev->x >= selmon->ww - wstext + lrpad / 2) {
  122. + click = ClkStatusText;
  123. +// updatedwmblockssig(x, ev->x);
  124. + } else
  125. + return;
  126. } else if ((c = wintoclient(ev->window))) {
  127. focus(c);
  128. restack(selmon);
  129. @@ -695,7 +712,7 @@
  130. void
  131. drawbar(Monitor *m)
  132. {
  133. - int x, w, sw = 0;
  134. + int x, w;
  135. int boxs = drw->fonts->h / 9;
  136. int boxw = drw->fonts->h / 6 + 2;
  137. unsigned int i, occ = 0, urg = 0;
  138. @@ -703,9 +720,30 @@
  139. /* draw status first so it can be overdrawn by tags later */
  140. if (m == selmon) { /* status is only drawn on selected monitor */
  141. - drw_setscheme(drw, scheme[SchemeNorm]);
  142. - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
  143. - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
  144. + char *ts = stextc;
  145. + char *tp = stextc;
  146. + char ctmp;
  147. +
  148. + drw_setscheme(drw, scheme[SchemeNorm]);
  149. + x = drw_text(drw, m->ww - wstext, 0, lrpad / 2, bh, 0, "", 0); /* to keep left padding clean */
  150. + for (;;) {
  151. + if ((unsigned char)*ts > LENGTH(colors) + 10) {
  152. + ts++;
  153. + continue;
  154. + }
  155. + ctmp = *ts;
  156. + *ts = '\0';
  157. + if (*tp != '\0')
  158. + x = drw_text(drw, x, 0, TTEXTW(tp), bh, 0, tp, 0);
  159. + if (ctmp == '\0')
  160. + break;
  161. + /* - 11 to compensate for + 10 above */
  162. + drw_setscheme(drw, scheme[(unsigned char)ctmp - 11]);
  163. + *ts = ctmp;
  164. + tp = ++ts;
  165. + }
  166. + drw_setscheme(drw, scheme[SchemeNorm]);
  167. + drw_text(drw, x, 0, m->ww - x, bh, 0, "", 0); /* to keep right padding clean */
  168. }
  169. for (c = m->clients; c; c = c->next) {
  170. @@ -728,7 +766,7 @@
  171. drw_setscheme(drw, scheme[SchemeNorm]);
  172. x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
  173. - if ((w = m->ww - sw - x) > bh) {
  174. + if ((w = m->ww - wstext - x) > bh) {
  175. if (m->sel) {
  176. drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
  177. drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
  178. @@ -1122,8 +1160,11 @@
  179. Monitor *m;
  180. XMotionEvent *ev = &e->xmotion;
  181. - if (ev->window != root)
  182. + if (ev->window != root) {
  183. + if (ev->window == selmon->barwin)
  184. + updatebarcursor(ev->x);
  185. return;
  186. + }
  187. if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
  188. unfocus(selmon->sel, 1);
  189. selmon = m;
  190. @@ -1564,6 +1605,7 @@
  191. netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
  192. /* init cursors */
  193. cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
  194. + cursor[CurHand] = drw_cur_create(drw, XC_hand2);
  195. cursor[CurResize] = drw_cur_create(drw, XC_sizing);
  196. cursor[CurMove] = drw_cur_create(drw, XC_fleur);
  197. /* init appearance */
  198. @@ -1637,6 +1679,28 @@
  199. }
  200. void
  201. +sigdwmblocks(const Arg *arg)
  202. +{
  203. + int fd;
  204. + struct flock fl;
  205. + union sigval sv;
  206. +
  207. + if (dwmblockssig <= 0 || dwmblockssig >= 10)
  208. + return;
  209. + sv.sival_int = (dwmblockssig << 8) | arg->i;
  210. + fd = open(DWMBLOCKSLOCKFILE, O_RDONLY);
  211. + if (fd == -1)
  212. + return;
  213. + fl.l_type = F_WRLCK;
  214. + fl.l_start = 0;
  215. + fl.l_whence = SEEK_SET;
  216. + fl.l_len = 0;
  217. + if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
  218. + return;
  219. + sigqueue(fl.l_pid, SIGRTMIN, sv);
  220. +}
  221. +
  222. +void
  223. spawn(const Arg *arg)
  224. {
  225. if (arg->v == dmenucmd)
  226. @@ -1805,7 +1869,7 @@
  227. XSetWindowAttributes wa = {
  228. .override_redirect = True,
  229. .background_pixmap = ParentRelative,
  230. - .event_mask = ButtonPressMask|ExposureMask
  231. + .event_mask = ButtonPressMask|ExposureMask|PointerMotionMask
  232. };
  233. XClassHint ch = {"dwm", "dwm"};
  234. for (m = mons; m; m = m->next) {
  235. @@ -1821,6 +1885,33 @@
  236. }
  237. void
  238. +updatebarcursor(int cursorpos)
  239. +{
  240. + static int currentcursor = 0;
  241. + int x;
  242. +
  243. + if (BETWEEN(cursorpos, (x = selmon->ww - wstext + lrpad / 2), x + wstext - lrpad)) {
  244. + updatedwmblockssig(x, cursorpos);
  245. + if (currentcursor) {
  246. + if (dwmblockssig <= 0 || dwmblockssig >= 10) {
  247. + currentcursor = 0;
  248. + XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
  249. + }
  250. + } else {
  251. + if (dwmblockssig > 0 && dwmblockssig < 10) {
  252. + currentcursor = 1;
  253. + XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
  254. + }
  255. + }
  256. + } else {
  257. + if (currentcursor) {
  258. + currentcursor = 0;
  259. + XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
  260. + }
  261. + }
  262. +}
  263. +
  264. +void
  265. updatebarpos(Monitor *m)
  266. {
  267. m->wy = m->my;
  268. @@ -1847,6 +1938,31 @@
  269. (unsigned char *) &(c->win), 1);
  270. }
  271. +void
  272. +updatedwmblockssig(int x, int e)
  273. +{
  274. + char *ts = stexts;
  275. + char *tp = stexts;
  276. + char ctmp;
  277. +
  278. + while (*ts != '\0') {
  279. + if ((unsigned char)*ts > 10) {
  280. + ts++;
  281. + continue;
  282. + }
  283. + ctmp = *ts;
  284. + *ts = '\0';
  285. + x += TTEXTW(tp);
  286. + *ts = ctmp;
  287. + if (x >= e) {
  288. + dwmblockssig = (unsigned char)ctmp;
  289. + return;
  290. + }
  291. + tp = ++ts;
  292. + }
  293. + dwmblockssig = 0;
  294. +}
  295. +
  296. int
  297. updategeom(void)
  298. {
  299. @@ -1987,9 +2103,27 @@
  300. void
  301. updatestatus(void)
  302. {
  303. - if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
  304. - strcpy(stext, "dwm-"VERSION);
  305. - drawbar(selmon);
  306. + char rawstext[256];
  307. +
  308. + if (gettextprop(root, XA_WM_NAME, rawstext, sizeof rawstext)) {
  309. + char stextt[256];
  310. + char *stc = stextc, *sts = stexts, *stt = stextt;
  311. +
  312. + for (char *rt = rawstext; *rt != '\0'; rt++)
  313. + if ((unsigned char)*rt >= ' ')
  314. + *(stc++) = *(sts++) = *(stt++) = *rt;
  315. + else if ((unsigned char)*rt > 10)
  316. + *(stc++) = *rt;
  317. + else
  318. + *(sts++) = *rt;
  319. + *stc = *sts = *stt = '\0';
  320. + wstext = TEXTW(stextt);
  321. + } else {
  322. + strcpy(stextc, "dwm-"VERSION);
  323. + strcpy(stexts, stextc);
  324. + wstext = TEXTW(stextc);
  325. + }
  326. + drawbar(selmon);
  327. }
  328. void