From f88cf9c46ac1616e5abe4846c97a6edb0fd9b87d Mon Sep 17 00:00:00 2001 From: odrling Date: Wed, 20 Apr 2022 20:26:55 +0200 Subject: [PATCH 20/26] better taglabels --- config.def.h | 8 +++++--- dwm.c | 7 +++++++ patch/bar_taglabels.c | 10 ++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 97226f8..a291b34 100644 --- a/config.def.h +++ b/config.def.h @@ -92,8 +92,8 @@ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int showsystray = 1; /* 0 means no systray */ #endif // BAR_SYSTRAY_PATCH #if BAR_TAGLABELS_PATCH -static const char ptagf[] = "[%s %s]"; /* format of a tag label */ -static const char etagf[] = "[%s]"; /* format of an empty tag */ +static const char ptagf[] = "%s: %s"; /* format of a tag label */ +static const char etagf[] = "%s"; /* format of an empty tag */ static const int lcaselbl = 0; /* 1 means make tag label lowercase */ #endif // BAR_TAGLABELS_PATCH #if BAR_UNDERLINETAGS_PATCH @@ -464,7 +464,9 @@ static const Rule rules[] = { RULE(.class = "Agordejo", .tags = 1 << 8, .monitor = 0, .ispermanent = 1) RULE(.class = "qBittorrent", .tags = 1 << 6, .switchtag = 1, .monitor = 0) RULE(.class = "mpv", .instance = "syncplay-mpv", .monitor = 1) - RULE(.class = "Alacritty", .isterminal = 1) + RULE(.class = "Alacritty", .isterminal = 1, .label = "\uf120") + RULE(.class = "Chromium-browser-chromium", .label = "\uf268") + RULE(.class = "firefox", .label = "\uf269") #if SCRATCHPADS_PATCH RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1) #endif // SCRATCHPADS_PATCH diff --git a/dwm.c b/dwm.c index 6b66f77..bb0ad84 100644 --- a/dwm.c +++ b/dwm.c @@ -339,6 +339,7 @@ struct XkbInfo { typedef struct Client Client; struct Client { char name[256]; + char label[48]; float mina, maxa; #if CFACTS_PATCH float cfact; @@ -524,6 +525,7 @@ typedef struct { #endif // WINDOWROLERULE_PATCH const char *instance; const char *title; + const char *label; const char *wintype; unsigned int tags; #if SWITCHTAG_PATCH @@ -866,6 +868,9 @@ applyrules(Client *c) class = ch.res_class ? ch.res_class : broken; instance = ch.res_name ? ch.res_name : broken; wintype = getatomprop(c, netatom[NetWMWindowType], XA_ATOM); + + snprintf(c->label, 48, "%s", class); + #if WINDOWROLERULE_PATCH gettextprop(c->win, wmatom[WMWindowRole], role, sizeof(role)); #endif // WINDOWROLERULE_PATCH @@ -885,6 +890,8 @@ applyrules(Client *c) && (!r->instance || strstr(instance, r->instance)) && (!r->wintype || wintype == XInternAtom(dpy, r->wintype, False))) { + if (r->label) snprintf(c->label, 48, "%s", r->label); + #if CENTER_PATCH c->iscentered = r->iscentered; #endif // CENTER_PATCH diff --git a/patch/bar_taglabels.c b/patch/bar_taglabels.c index 9e6d441..f00a7be 100644 --- a/patch/bar_taglabels.c +++ b/patch/bar_taglabels.c @@ -17,17 +17,15 @@ width_taglabels(Bar *bar, BarArg *a) continue; #endif // BAR_HIDEVACANTTAGS_PATCH icon = tagicon(m, i); - XClassHint ch = { NULL, NULL }; + char *label = NULL; for (c = m->clients; c; c = c->next) { if (c->tags & (1 << i)) { - XGetClassHint(dpy, c->win, &ch); + label = c->label; break; } } - if (ch.res_class) { - if (lcaselbl) - ch.res_class[0] = tolower(ch.res_class[0]); - snprintf(m->taglabel[i], 64, ptagf, icon, ch.res_class); + if (label) { + snprintf(m->taglabel[i], 64, ptagf, icon, label); } else snprintf(m->taglabel[i], 64, etagf, icon); -- 2.35.1