aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-08-17 20:18:18 +0200
committerJoe <bousset.rudy@gmail.com>2022-08-17 20:18:18 +0200
commit91a906ecf692a1ee4b1332e5a31d811fcab89ec7 (patch)
tree048620915072b7483c01743d7f4d3252f956c080
parentupdate (diff)
downloaddwm-91a906ecf692a1ee4b1332e5a31d811fcab89ec7.tar.gz
dwm-91a906ecf692a1ee4b1332e5a31d811fcab89ec7.tar.bz2
dwm-91a906ecf692a1ee4b1332e5a31d811fcab89ec7.tar.xz
dwm-91a906ecf692a1ee4b1332e5a31d811fcab89ec7.tar.zst
dwm-91a906ecf692a1ee4b1332e5a31d811fcab89ec7.zip
Actually cool setp
-rw-r--r--applied/dwm-fancybar-20220527-d3f93c7.diff73
-rw-r--r--dwm.c46
2 files changed, 109 insertions, 10 deletions
diff --git a/applied/dwm-fancybar-20220527-d3f93c7.diff b/applied/dwm-fancybar-20220527-d3f93c7.diff
new file mode 100644
index 0000000..e2a4e2a
--- /dev/null
+++ b/applied/dwm-fancybar-20220527-d3f93c7.diff
@@ -0,0 +1,73 @@
+diff --git a/dwm.c b/dwm.c
+--- a/dwm.c
++++ b/dwm.c
+@@ -699,10 +699,10 @@ dirtomon(int dir)
+ void
+ drawbar(Monitor *m)
+ {
+- int x, w, tw = 0;
++ int x, w, tw = 0, mw, ew = 0;
+ int boxs = drw->fonts->h / 9;
+ int boxw = drw->fonts->h / 6 + 2;
+- unsigned int i, occ = 0, urg = 0;
++ unsigned int i, occ = 0, urg = 0, n = 0;
+ Client *c;
+
+ if (!m->showbar)
+@@ -716,6 +716,8 @@ drawbar(Monitor *m)
+ }
+
+ for (c = m->clients; c; c = c->next) {
++ if (ISVISIBLE(c))
++ n++;
+ occ |= c->tags;
+ if (c->isurgent)
+ urg |= c->tags;
+@@ -736,15 +738,39 @@ drawbar(Monitor *m)
+ 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);
++ if (n > 0) {
++ tw = TEXTW(m->sel->name) + lrpad;
++ mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1);
++
++ i = 0;
++ for (c = m->clients; c; c = c->next) {
++ if (!ISVISIBLE(c) || c == m->sel)
++ continue;
++ tw = TEXTW(c->name);
++ if(tw < mw)
++ ew += (mw - tw);
++ else
++ i++;
++ }
++ if (i > 0)
++ mw += ew / i;
++
++ for (c = m->clients; c; c = c->next) {
++ if (!ISVISIBLE(c))
++ continue;
++ tw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
++
++ drw_setscheme(drw, scheme[m == selmon && m->sel == c ? SchemeSel : SchemeNorm]);
++ if (tw > lrpad / 2)
++ drw_text(drw, x, 0, tw, bh, lrpad / 2, c->name, 0);
++ if (c->isfloating)
++ drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
++ x += tw;
++ w -= tw;
++ }
+ }
++ drw_setscheme(drw, scheme[SchemeNorm]);
++ drw_rect(drw, x, 0, w, bh, 1, 1);
+ }
+ drw_map(drw, m->barwin, 0, 0, m->ww, bh);
+ }
diff --git a/dwm.c b/dwm.c
index 282a299..5a164d2 100644
--- a/dwm.c
+++ b/dwm.c
@@ -777,10 +777,10 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
- int x, w, tw = 0;
+ int x, w, tw = 0, mw, ew = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
- unsigned int i, occ = 0, urg = 0;
+ unsigned int i, occ = 0, urg = 0, n = 0;
Client *c;
if (!m->showbar)
@@ -794,6 +794,8 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
+ if (ISVISIBLE(c))
+ n++;
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
@@ -818,15 +820,39 @@ drawbar(Monitor *m)
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);
+ if (n > 0) {
+ tw = TEXTW(m->sel->name) + lrpad;
+ mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1);
+
+ i = 0;
+ for (c = m->clients; c; c = c->next) {
+ if (!ISVISIBLE(c) || c == m->sel)
+ continue;
+ tw = TEXTW(c->name);
+ if(tw < mw)
+ ew += (mw - tw);
+ else
+ i++;
+ }
+ if (i > 0)
+ mw += ew / i;
+
+ for (c = m->clients; c; c = c->next) {
+ if (!ISVISIBLE(c))
+ continue;
+ tw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
+
+ drw_setscheme(drw, scheme[m == selmon && m->sel == c ? SchemeSel : SchemeNorm]);
+ if (tw > lrpad / 2)
+ drw_text(drw, x, 0, tw, bh, lrpad / 2, c->name, 0);
+ if (c->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
+ x += tw;
+ w -= tw;
+ }
}
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, x, 0, w, bh, 1, 1);
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}