No, I want unused tags hidden.

This commit is contained in:
Bartek Stalewski 2021-07-26 16:43:47 +02:00
parent 4508f38520
commit dc9d5df7e4
4 changed files with 121 additions and 63 deletions

View file

@ -13,5 +13,5 @@ for battery in /sys/class/power_supply/BAT?*; do
esac
capacity=$(cat "$battery/capacity")
# Will make a warn variable if discharging and low
[ "$capacity" -le 20 ] && printf "\ue19c ^c#161616^^b#fd4285^${capacity}%%^d^" || printf "${status} ${capacity}%%"
[ "$capacity" -le 20 ] && printf "^c#161616^^b#fd4285^\ue19c ${capacity}%%^d^" || printf "${status} ${capacity}%%"
done && exit 0

View file

@ -39,7 +39,7 @@ static Sp scratchpads[] = {
};
/* tagging */
static const char *tags[] = {"\ue9ef", "\ue894", "\ue0c9", "\ue0e1", "\ue3fe", "\ue3ff", "\ue943", "\uea67" };
static const char *tags[] = {"\ue9ef", "\ue894", "\ue0c9", "\ue0e1", "\ue3fe", "\ue3ff", "7", "8", "\ue943", "\uea67" };
static const Rule rules[] = {
/* xprop(1):
@ -54,7 +54,7 @@ static const Rule rules[] = {
{ "Thunderbird", NULL, NULL, 1 << 3, 0, 0, 0, -1 },
{ "Wfica", NULL, NULL, 1 << 9, 0, 0, 0, -1 },
{ "Pavucontrol", NULL, NULL, 0, 1, 0, 0, -1 },
{ NULL, NULL, "Citrix Workspace", 1 << 6, 0, 0, 0, -1 },
{ NULL, NULL, "Citrix Workspace", 1 << 8, 0, 0, 0, -1 },
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
{ NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1 },
{ NULL, "spfile", NULL, SPTAG(1), 1, 1, 0, -1 },

View file

@ -554,7 +554,7 @@ unswallow(Client *c)
void
buttonpress(XEvent *e)
{
unsigned int i, x, click;
unsigned int i, x, click, occ = 0;
Arg arg = {0};
Client *c;
Monitor *m;
@ -569,9 +569,14 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
do
for (c = m->clients; c; c = c->next)
occ |= c->tags == 255 ? 0 : c->tags;
do {
/* do not reserve space for vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
x += TEXTW(tags[i]);
while (ev->x >= x && ++i < LENGTH(tags));
} while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@ -1004,8 +1009,6 @@ void
drawbar(Monitor *m)
{
int x, w, tw = 0, stw = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
@ -1020,19 +1023,19 @@ drawbar(Monitor *m)
resizebarwin(m);
for (c = m->clients; c; c = c->next) {
occ |= c->tags;
occ |= c->tags == 255 ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
/* do not draw vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
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);

View file

@ -0,0 +1,55 @@
diff --git a/dwm.c b/dwm.c
index 4465af1..c4aa3de 100644
--- a/dwm.c
+++ b/dwm.c
@@ -416,7 +416,7 @@ attachstack(Client *c)
void
buttonpress(XEvent *e)
{
- unsigned int i, x, click;
+ unsigned int i, x, click, occ = 0;
Arg arg = {0};
Client *c;
Monitor *m;
@@ -431,9 +431,14 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
- do
+ for (c = m->clients; c; c = c->next)
+ occ |= c->tags == 255 ? 0 : c->tags;
+ do {
+ /* do not reserve space for vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
+ } while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -709,19 +714,19 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
- occ |= c->tags;
+ occ |= c->tags == 255 ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* do not draw vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
+
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);