commit 6dc3312ed0b0e5fe7d08c0f03e61cc35f47192df
parent 9bc22717ca656a99ca3966128c01b1c4ed32a8c9
Author: hhvn <hayden@haydenvh.com>
Date: Sun, 22 Nov 2020 13:37:00 +0000
dwm.c config.h: partially import and modify `awesomebar` patch
Diffstat:
M | config.h | | | 3 | ++- |
M | dwm.c | | | 37 | ++++++++++++++++++++++++++++++------- |
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/config.h b/config.h
@@ -8,7 +8,7 @@ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=8" };
static const char col_gray1[] = "#0a0a10";
-static const char col_gray2[] = "#444444";
+static const char col_gray2[] = "#141726";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#30404e";
@@ -19,6 +19,7 @@ static const char *colors[][3] = {
[SchemeNorm] = { col_gray3, col_gray1, col_gray1 },
[SchemeSel] = { col_gray4, col_cyan, col_red },
[SchemeStat] = { col_gray4, col_stat, col_stat },
+ [SchemeNormWin] = { col_gray3, col_gray2, col_gray1 },
};
/* tagging */
diff --git a/dwm.c b/dwm.c
@@ -68,7 +68,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel, SchemeStat, SchemeStatAlt }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeStat, SchemeNormWin }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -123,6 +123,8 @@ struct Monitor {
int nmaster;
int num;
int by; /* bar geometry */
+ int btw; /* width of tasks portion of bar */
+ int bt; /* number of tasks */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
int gappx; /* gaps between windows */
@@ -786,7 +788,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
void
drawbar(Monitor *m)
{
- int x, w, sw = 0;
+ int x, w, sw = 0, n = 0, scm;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
@@ -799,6 +801,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;
@@ -819,16 +823,35 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - 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);
+ if (n > 0) {
+ int remainder = w % n;
+ int tabw = (1.0 / (double)n) * w + 1;
+ for (c = m->clients; c; c = c->next) {
+ if (!ISVISIBLE(c))
+ continue;
+ if (m->sel == c)
+ scm = SchemeSel;
+ else
+ scm = SchemeNormWin;
+ drw_setscheme(drw, scheme[scm]);
+
+ if (remainder >= 0) {
+ if (remainder == 0) {
+ tabw--;
+ }
+ remainder--;
+ }
+ drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
+ x += tabw;
+ }
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}
+
+ m->bt = n;
+ m->btw = w;
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}