summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2020-06-22 01:05:21 -0400
committerMalfurious <m@lfurio.us>2023-06-03 21:48:54 -0400
commit008f8a61770c966a2a644ee8fa9a9dd15c84799d (patch)
tree2eed150a8146959eed7820a3ed5ec811027a7de3 /dwm.c
parentfc63e62e14aa5ffe340e13e339c597686a82adcd (diff)
downloaddwm-008f8a61770c966a2a644ee8fa9a9dd15c84799d.tar.gz
dwm-008f8a61770c966a2a644ee8fa9a9dd15c84799d.zip
patch: autobar
dwm will automatically hide the monitor's statusbar when only 1 tag is being utilized (viewing an empty tag counts as 'utilization'). The hotkey for controlling visibility manually is removed, and all monitors default to statusbar hidden at startup (since no clients would be active).
Diffstat (limited to '')
-rw-r--r--dwm.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/dwm.c b/dwm.c
index 7ca234b..672a4e2 100644
--- a/dwm.c
+++ b/dwm.c
@@ -211,7 +211,6 @@ static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
-static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -390,6 +389,21 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
void
arrange(Monitor *m)
{
+ unsigned int occ;
+ Client *c;
+
+ if (m)
+ {
+ occ = m->tagset[m->seltags];
+
+ for (c = m->clients; c; c = c->next)
+ occ |= c->tags;
+
+ selmon->showbar = __builtin_popcount(occ & TAGMASK) > 1;
+ updatebarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ }
+
if (m)
showhide(m->stack);
else for (m = mons; m; m = m->next)
@@ -647,7 +661,7 @@ createmon(void)
m->tagset[0] = m->tagset[1] = 1;
m->mfact = mfact;
m->nmaster = nmaster;
- m->showbar = showbar;
+ m->showbar = 0;
m->topbar = topbar;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
@@ -1722,15 +1736,6 @@ tile(Monitor *m)
}
void
-togglebar(const Arg *arg)
-{
- selmon->showbar = !selmon->showbar;
- updatebarpos(selmon);
- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
- arrange(selmon);
-}
-
-void
togglefloating(const Arg *arg)
{
if (!selmon->sel)