commit 62423eba82732dea63752f06b8c6b7fe0d07753d
Author: Dylan Cairns-Howarth <[email protected]>
Date:   Mon Mar 14 22:03:17 2022 +0000

    [dwm][patch][barconfig] first release
    
    Allow bar order to be configured by a string in config.h.
    By default, this patch leaves the bar as is.

diff --git a/dwm.suckless.org/patches/barconfig/dwm-barconfig-6.3.diff 
b/dwm.suckless.org/patches/barconfig/dwm-barconfig-6.3.diff
new file mode 100644
index 00000000..bc0ce2e1
--- /dev/null
+++ b/dwm.suckless.org/patches/barconfig/dwm-barconfig-6.3.diff
@@ -0,0 +1,183 @@
+From 711d36b37cc3d27b23241bb3d66addb1e169082a Mon Sep 17 00:00:00 2001
+From: Dylan Cairns-Howarth <[email protected]>
+Date: Tue, 22 Feb 2022 07:24:52 +0000
+Subject: [PATCH] Allow bar order to be configured in config.h
+
+This patch adds char *barlayout to config(.def).h which can contain as
+many or as few of the characters 'l', 'n', 's', 't', or '|' to configure
+the order of dwm's bar.
+
+    l   Layout indicator;
+    n   Window name;
+    s   Status (set with xsetroot);
+    t   Tag indicators;
+    |   Split point.
+
+Everything before '|' (and if it is omitted) will appear on the left of
+the bar. Everything after will appear on the right, but in reverse
+order.
+
+By default, this patch leaves the bar as is.
+---
+ config.def.h |   2 +-
+ dwm.c        | 117 +++++++++++++++++++++++++++++++++++----------------
+ 2 files changed, 81 insertions(+), 38 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..260799e 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -5,6 +5,7 @@ static const unsigned int borderpx  = 1;        /* border 
pixel of windows */
+ static const unsigned int snap      = 32;       /* snap pixel */
+ static const int showbar            = 1;        /* 0 means no bar */
+ static const int topbar             = 1;        /* 0 means bottom bar */
++static const char *barlayout        = "tln|s";
+ static const char *fonts[]          = { "monospace:size=10" };
+ static const char dmenufont[]       = "monospace:size=10";
+ static const char col_gray1[]       = "#222222";
+@@ -113,4 +114,3 @@ static Button buttons[] = {
+       { ClkTagBar,            MODKEY,         Button1,        tag,            
{0} },
+       { ClkTagBar,            MODKEY,         Button3,        toggletag,      
{0} },
+ };
+-
+diff --git a/dwm.c b/dwm.c
+index a96f33c..edbce8d 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -696,53 +696,96 @@ dirtomon(int dir)
+ void
+ drawbar(Monitor *m)
+ {
+-      int x, w, tw = 0;
++      int x = 0, w, tw = 0, moveright = 0;
+       int boxs = drw->fonts->h / 9;
+       int boxw = drw->fonts->h / 6 + 2;
+-      unsigned int i, occ = 0, urg = 0;
++      unsigned int i, j, occ = 0, urg = 0;
+       Client *c;
+ 
+       if (!m->showbar)
+               return;
++      if (barlayout[0] == '++         barlayout = "tln|s";
+ 
+-      /* draw status first so it can be overdrawn by tags later */
+-      if (m == selmon) { /* status is only drawn on selected monitor */
+-              drw_setscheme(drw, scheme[SchemeNorm]);
+-              tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+-              drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
+-      }
+-
+-      for (c = m->clients; c; c = c->next) {
+-              occ |= c->tags;
+-              if (c->isurgent)
+-                      urg |= c->tags;
+-      }
+-      x = 0;
+-      for (i = 0; i < LENGTH(tags); i++) {
+-              w = TEXTW(tags[i]);
+-              drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? 
SchemeSel : SchemeNorm]);
+-              drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+-              if (occ & 1 << i)
+-                      drw_rect(drw, x + boxs, boxs, boxw, boxw,
+-                              m == selmon && selmon->sel && selmon->sel->tags 
& 1 << i,
+-                              urg & 1 << i);
+-              x += w;
+-      }
+-      w = blw = TEXTW(m->ltsymbol);
+       drw_setscheme(drw, scheme[SchemeNorm]);
+-      x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
+-
+-      if ((w = m->ww - tw - x) > bh) {
+-              if (m->sel) {
+-                      drw_setscheme(drw, scheme[m == selmon ? SchemeSel : 
SchemeNorm]);
+-                      drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
+-                      if (m->sel->isfloating)
+-                              drw_rect(drw, x + boxs, boxs, boxw, boxw, 
m->sel->isfixed, 0);
+-              } else {
+-                      drw_setscheme(drw, scheme[SchemeNorm]);
+-                      drw_rect(drw, x, 0, w, bh, 1, 1);
++      drw_text(drw, 0, 0, m->ww, bh, 0, "", 0); /* draw background */
++
++      for (i = 0; i < strlen(barlayout); i++) {
++              switch (barlayout[i]) {
++                      case 'l':
++                              w = blw = TEXTW(m->ltsymbol);
++                              drw_setscheme(drw, scheme[SchemeNorm]);
++                              if (moveright) {
++                                      x -= w;
++                                      drw_text(drw, x, 0, w, bh, lrpad / 2, 
m->ltsymbol, 0);
++                              } else
++                                      x = drw_text(drw, x, 0, w, bh, lrpad / 
2, m->ltsymbol, 0);
++                              break;
++
++                      case 'n':
++                              tw = TEXTW(m->sel->name);
++                              if (moveright)
++                                      x -= tw;
++                              if (m->sel) {
++                                      drw_setscheme(drw, scheme[m == selmon ? 
SchemeSel : SchemeNorm]);
++                                      drw_text(drw, x, 0, moveright ? tw : 
m->ww, bh, lrpad / 2, m->sel->name, 0);
++                                      if (m->sel->isfloating)
++                                              drw_rect(drw, x + boxs, boxs, 
boxw, boxw, m->sel->isfixed, 0);
++                              } else {
++                                      drw_setscheme(drw, scheme[SchemeNorm]);
++                                      drw_rect(drw, x, 0, tw, bh, 1, 1);
++                              }
++                              if (!moveright)
++                                      x += tw;
++                              break;
++
++                      case 's':
++                              if (m == selmon) { /* status is only drawn on 
selected monitor */
++                                      drw_setscheme(drw, scheme[SchemeNorm]);
++                                      tw = TEXTW(stext) - lrpad + 2; /* 2px 
right padding */
++                                      if (moveright) {
++                                              x -= tw;
++                                              drw_text(drw, x, 0, tw, bh, 0, 
stext, 0);
++                                      } else
++                                              x = drw_text(drw, x, 0, tw, bh, 
0, stext, 0);
++                              }
++                              break;
++
++                      case 't':
++                              for (c = m->clients; c; c = c->next) {
++                                      occ |= c->tags;
++                                      if (c->isurgent)
++                                              urg |= c->tags;
++                              }
++                              /* tags */
++                              if (moveright) {
++                                      tw = 0;
++                                      for (j = 0; j < LENGTH(tags); j++) {
++                                              tw += TEXTW(tags[j]);
++                                      }
++                                      x -= tw;
++                              }
++                              for (j = 0; j < LENGTH(tags); j++) {
++                                      w = TEXTW(tags[j]);
++                                      drw_setscheme(drw, 
scheme[m->tagset[m->seltags] & 1 << j ? SchemeSel : SchemeNorm]);
++                                      drw_text(drw, x, 0, w, bh, lrpad / 2, 
tags[j], urg & 1 << j);
++                                      if (occ & 1 << j)
++                                              drw_rect(drw, x + boxs, boxs, 
boxw, boxw,
++                                                      m == selmon && 
selmon->sel && selmon->sel->tags & 1 << j,
++                                                      urg & 1 << i);
++                                      x += w;
++                              }
++                              if (moveright)
++                                      x -= tw;
++                              break;
++
++                      case '|':
++                              moveright = 1;
++                              x = m->ww;
++                              break;
+               }
+       }
++
+       drw_map(drw, m->barwin, 0, 0, m->ww, bh);
+ }
+ 
+-- 
+2.35.1
+
diff --git a/dwm.suckless.org/patches/barconfig/index.md 
b/dwm.suckless.org/patches/barconfig/index.md
new file mode 100644
index 00000000..a898a959
--- /dev/null
+++ b/dwm.suckless.org/patches/barconfig/index.md
@@ -0,0 +1,25 @@
+barconfig
+=========
+
+Description
+-----------
+This patch adds char \*barlayout to config(.def).h which can contain as
+many or as few of the characters 'l', 'n', 's', 't', or '|' to configure the 
order of dwm's bar.
+
+* l: layout indicator
+* n: window name
+* s: status (xsetroot)
+* t: tag indicators
+* |: split point
+
+Everything before '|' (and if it is omitted) will appear on the left of the 
bar. Everything after will appear on the right, but in reverse order.
+
+By default, this patch leaves the bar as is.
+
+Download
+--------
+* [dwm-barconfig-6.3.diff](dwm-barconfig-6.3.diff) (2022-02-22)
+
+Author
+-------
+* Dylan Cairns-Howarth - <[email protected]>


Reply via email to