mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding taglabels patch ref. #199
This commit is contained in:
parent
c7af5c6b67
commit
63fed59d19
@ -17,6 +17,8 @@ If you are experiencing issues then you may want to check out the [Known Issues]
|
||||
|
||||
### Changelog:
|
||||
|
||||
2021-11-23 - Added the taglabels patch
|
||||
|
||||
2021-09-08 - Added the alwayscenter patch
|
||||
|
||||
2021-07-27 - Added the winicon patch
|
||||
@ -703,6 +705,9 @@ If you are experiencing issues then you may want to check out the [Known Issues]
|
||||
- [taggrid](https://dwm.suckless.org/patches/taggrid/)
|
||||
- adds an option to place tags in rows like in many other window managers
|
||||
|
||||
- [taglabels](https://dwm.suckless.org/patches/taglabels/)
|
||||
- shows tag + class of master client in the tags section of the bar
|
||||
|
||||
- [tagmonfixfs](https://github.com/bakkeby/patches/wiki/tagmonfixfs/)
|
||||
- allows moving a fullscreen window to another monitor while remaining in fullscreen
|
||||
|
||||
|
@ -91,6 +91,12 @@ static const char buttonbar[] = "<O>";
|
||||
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 int lcaselbl = 0; /* 1 means make tag label lowercase */
|
||||
#endif // BAR_TAGLABELS_PATCH
|
||||
|
||||
/* Indicators: see patch/bar_indicators.h for options */
|
||||
static int tagindicatortype = INDICATOR_TOP_LEFT_SQUARE;
|
||||
static int tiledindicatortype = INDICATOR_NONE;
|
||||
@ -480,6 +486,9 @@ static const BarRule barrules[] = {
|
||||
#if BAR_TAGS_PATCH
|
||||
{ -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" },
|
||||
#endif // BAR_TAGS_PATCH
|
||||
#if BAR_TAGLABELS_PATCH
|
||||
{ -1, 0, BAR_ALIGN_LEFT, width_taglabels, draw_taglabels, click_taglabels, "taglabels" },
|
||||
#endif // BAR_TAGLABELS_PATCH
|
||||
#if BAR_TAGGRID_PATCH
|
||||
{ -1, 0, BAR_ALIGN_LEFT, width_taggrid, draw_taggrid, click_taggrid, "taggrid" },
|
||||
#endif // BAR_TAGGRID_PATCH
|
||||
|
3
dwm.c
3
dwm.c
@ -485,6 +485,9 @@ struct Monitor {
|
||||
#if INSETS_PATCH
|
||||
Inset inset;
|
||||
#endif // INSETS_PATCH
|
||||
#if BAR_TAGLABELS_PATCH
|
||||
char taglabel[NUMTAGS][64];
|
||||
#endif // BAR_TAGLABELS_PATCH
|
||||
#if IPC_PATCH
|
||||
char lastltsymbol[16];
|
||||
TagState tagstate;
|
||||
|
87
patch/bar_taglabels.c
Normal file
87
patch/bar_taglabels.c
Normal file
@ -0,0 +1,87 @@
|
||||
int
|
||||
width_taglabels(Bar *bar, BarArg *a)
|
||||
{
|
||||
int w, i;
|
||||
Client *c;
|
||||
Monitor *m = bar->mon;
|
||||
char *icon;
|
||||
unsigned int occ = 0;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
|
||||
for (w = 0, i = 0; i < NUMTAGS; i++) {
|
||||
m->taglabel[i][0] = '\0';
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
icon = tagicon(m, i);
|
||||
XClassHint ch = { NULL, NULL };
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->tags & (1 << i)) {
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
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);
|
||||
} else
|
||||
snprintf(m->taglabel[i], 64, etagf, icon);
|
||||
|
||||
w += TEXTW(m->taglabel[i]);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_taglabels(Bar *bar, BarArg *a)
|
||||
{
|
||||
int invert = 0;
|
||||
int w, x = a->x;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
Client *c;
|
||||
Monitor *m = bar->mon;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
/* do not draw vacant tags */
|
||||
if (!m->taglabel[i][0])
|
||||
continue;
|
||||
drw_setscheme(drw, scheme[
|
||||
m->tagset[m->seltags] & 1 << i
|
||||
? SchemeTagsSel
|
||||
: urg & 1 << i
|
||||
? SchemeUrg
|
||||
: SchemeTagsNorm
|
||||
]);
|
||||
w = TEXTW(m->taglabel[i]);
|
||||
drw_text(drw, x, a->y, w, a->h, lrpad / 2, m->taglabel[i], invert, False);
|
||||
drawindicator(m, NULL, occ, x, a->y, w, a->h, i, -1, invert, tagindicatortype);
|
||||
x += w;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
click_taglabels(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i = 0, x = lrpad / 2;
|
||||
Monitor *m = bar->mon;
|
||||
|
||||
do {
|
||||
if (!m->taglabel[i][0])
|
||||
continue;
|
||||
x += TEXTW(m->taglabel[i]);
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
if (i < NUMTAGS) {
|
||||
arg->ui = 1 << i;
|
||||
}
|
||||
return ClkTagBar;
|
||||
}
|
5
patch/bar_taglabels.h
Normal file
5
patch/bar_taglabels.h
Normal file
@ -0,0 +1,5 @@
|
||||
#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
|
||||
|
||||
static int width_taglabels(Bar *bar, BarArg *a);
|
||||
static int draw_taglabels(Bar *bar, BarArg *a);
|
||||
static int click_taglabels(Bar *bar, Arg *arg, BarArg *a);
|
@ -56,6 +56,9 @@
|
||||
#if BAR_TAGS_PATCH
|
||||
#include "bar_tags.c"
|
||||
#endif
|
||||
#if BAR_TAGLABELS_PATCH
|
||||
#include "bar_taglabels.c"
|
||||
#endif
|
||||
#if BAR_TAGGRID_PATCH
|
||||
#include "bar_taggrid.c"
|
||||
#endif
|
||||
|
@ -56,6 +56,9 @@
|
||||
#if BAR_TAGS_PATCH
|
||||
#include "bar_tags.h"
|
||||
#endif
|
||||
#if BAR_TAGLABELS_PATCH
|
||||
#include "bar_taglabels.h"
|
||||
#endif
|
||||
#if BAR_TAGGRID_PATCH
|
||||
#include "bar_taggrid.h"
|
||||
#endif
|
||||
|
@ -152,9 +152,14 @@
|
||||
*/
|
||||
#define BAR_SYSTRAY_PATCH 0
|
||||
|
||||
/* Show tag symbols in bar */
|
||||
/* Show tag symbols in the bar. */
|
||||
#define BAR_TAGS_PATCH 1
|
||||
|
||||
/* Show tag symbols + class of master window in the bar.
|
||||
* https://dwm.suckless.org/patches/taglabels/
|
||||
*/
|
||||
#define BAR_TAGLABELS_PATCH 0
|
||||
|
||||
/* This patch adds the window icon next to the window title in the bar.
|
||||
*
|
||||
* The patch depends on Imlib2 for icon scaling.
|
||||
|
Loading…
Reference in New Issue
Block a user