dwm-alternativetags-6.2.diff 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From 25aa44b5998a2aac840a0eecf9d8a479695b2577 Mon Sep 17 00:00:00 2001
  2. From: Piyush Pangtey <gokuvsvegita@gmail.com>
  3. Date: Sat, 13 Apr 2019 00:24:23 +0530
  4. Subject: [PATCH] alternative tags
  5. Having icons as tags sure makes dwm look awesome, but having tags number
  6. simplifies tags related operations. This patch introduces alternative
  7. tags which can be switched on the fly for the sole purpose of providing
  8. visual aid.
  9. Signed-off-by: Piyush Pangtey <gokuvsvegita@gmail.com>
  10. ---
  11. config.def.h | 2 ++
  12. dwm.c | 14 ++++++++++++--
  13. 2 files changed, 14 insertions(+), 2 deletions(-)
  14. diff --git a/config.def.h b/config.def.h
  15. index 1c0b587..e6c2565 100644
  16. --- a/config.def.h
  17. +++ b/config.def.h
  18. @@ -20,6 +20,7 @@ static const char *colors[][3] = {
  19. /* tagging */
  20. static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
  21. +static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
  22. static const Rule rules[] = {
  23. /* xprop(1):
  24. @@ -84,6 +85,7 @@ static Key keys[] = {
  25. { MODKEY, XK_period, focusmon, {.i = +1 } },
  26. { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
  27. { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
  28. + { MODKEY, XK_n, togglealttag, {0} },
  29. TAGKEYS( XK_1, 0)
  30. TAGKEYS( XK_2, 1)
  31. TAGKEYS( XK_3, 2)
  32. diff --git a/dwm.c b/dwm.c
  33. index 4465af1..ee292e1 100644
  34. --- a/dwm.c
  35. +++ b/dwm.c
  36. @@ -130,6 +130,7 @@ struct Monitor {
  37. Monitor *next;
  38. Window barwin;
  39. const Layout *lt[2];
  40. + unsigned int alttag;
  41. };
  42. typedef struct {
  43. @@ -209,6 +210,7 @@ static void spawn(const Arg *arg);
  44. static void tag(const Arg *arg);
  45. static void tagmon(const Arg *arg);
  46. static void tile(Monitor *);
  47. +static void togglealttag();
  48. static void togglebar(const Arg *arg);
  49. static void togglefloating(const Arg *arg);
  50. static void toggletag(const Arg *arg);
  51. @@ -695,7 +697,7 @@ dirtomon(int dir)
  52. void
  53. drawbar(Monitor *m)
  54. {
  55. - int x, w, sw = 0;
  56. + int x, w, wdelta, sw = 0;
  57. int boxs = drw->fonts->h / 9;
  58. int boxw = drw->fonts->h / 6 + 2;
  59. unsigned int i, occ = 0, urg = 0;
  60. @@ -716,8 +718,9 @@ drawbar(Monitor *m)
  61. x = 0;
  62. for (i = 0; i < LENGTH(tags); i++) {
  63. w = TEXTW(tags[i]);
  64. + wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0;
  65. drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
  66. - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
  67. + drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i);
  68. if (occ & 1 << i)
  69. drw_rect(drw, x + boxs, boxs, boxw, boxw,
  70. m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
  71. @@ -1696,6 +1699,13 @@ tile(Monitor *m)
  72. }
  73. }
  74. +void
  75. +togglealttag()
  76. +{
  77. + selmon->alttag = !selmon->alttag;
  78. + drawbar(selmon);
  79. +}
  80. +
  81. void
  82. togglebar(const Arg *arg)
  83. {
  84. --
  85. 2.21.0