diff options
Diffstat (limited to 'patch')
| -rwxr-xr-x | patch/dwmc | 1 | ||||
| -rw-r--r-- | patch/include.c | 3 | ||||
| -rw-r--r-- | patch/include.h | 3 | ||||
| -rw-r--r-- | patch/nametag.c | 61 | ||||
| -rw-r--r-- | patch/nametag.h | 1 |
5 files changed, 69 insertions, 0 deletions
@@ -10,6 +10,7 @@ case $# in focusurgent) ;& mirrorlayout) ;& mpdcontrol) ;& + nametag) ;& pushdown) ;& pushup) ;& self_restart) ;& diff --git a/patch/include.c b/patch/include.c index 33232cf..4263f45 100644 --- a/patch/include.c +++ b/patch/include.c @@ -193,6 +193,9 @@ #if MOVESTACK_PATCH #include "movestack.c" #endif +#if NAMETAG_PATCH +#include "nametag.c" +#endif #if NO_MOD_BUTTONS_PATCH #include "nomodbuttons.c" #endif diff --git a/patch/include.h b/patch/include.h index 2a78292..65e0eda 100644 --- a/patch/include.h +++ b/patch/include.h @@ -192,6 +192,9 @@ #if MOVESTACK_PATCH #include "movestack.h" #endif +#if NAMETAG_PATCH +#include "nametag.h" +#endif #if NO_MOD_BUTTONS_PATCH #include "nomodbuttons.h" #endif diff --git a/patch/nametag.c b/patch/nametag.c new file mode 100644 index 0000000..2b7b038 --- /dev/null +++ b/patch/nametag.c @@ -0,0 +1,61 @@ +void +nametag(const Arg *arg) +{ + char *p, name[MAX_TAGLEN]; + FILE *f; + int i, group; + int tagindex; + Monitor *m = selmon; + #if BAR_ALTTAGSDECORATION_PATCH + Client *c; + int occ = 0; + + for (c = m->clients; c; c = c->next) + occ |= c->tags == 255 ? 0 : c->tags; + #endif // BAR_ALTTAGSDECORATION_PATCH + + errno = 0; // popen(3p) says on failure it "may" set errno + if (!(f = popen(NAMETAG_COMMAND, "r"))) { + fprintf(stderr, "dwm: popen command failed%s%s\n", errno ? ": " : "", errno ? strerror(errno) : ""); + return; + } + + if (!(p = fgets(name, MAX_TAGLEN, f)) && (i = errno) && ferror(f)) + fprintf(stderr, "dwm: fgets failed: %s\n", strerror(i)); + + pclose(f); + + if (!p) + return; + if ((p = strchr(name, '\n'))) + *p = '\0'; + + for (i = 0; i < NUMTAGS; i++) { + if (m->tagset[m->seltags] & (1 << i)) { + + tagindex = i + NUMTAGS * m->num; + if (tagindex >= LENGTH(tagicons[DEFAULT_TAGS])) + tagindex = tagindex % LENGTH(tagicons[DEFAULT_TAGS]); + + #if BAR_ALTTAGSDECORATION_PATCH + if (occ & 1 << i) + group = ALT_TAGS_DECORATION; + else + #endif // BAR_ALTTAGSDECORATION_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH + if (m->alttag) + group = ALTERNATIVE_TAGS; + else + #endif // BAR_ALTERNATIVE_TAGS_PATCH + group = DEFAULT_TAGS; + + #if NAMETAG_PREPEND_PATCH + if (snprintf(tagicons[group][i], MAX_TAGLEN, NAMETAG_FORMAT, i+1, name) < 0) + fprintf(stderr, "nametag: if statement to avoid -Wformat-truncation= warnings\n"); + #else + snprintf(tagicons[group][i], MAX_TAGLEN, NAMETAG_FORMAT, name); + #endif // NAMETAG_PREPEND_PATCH + } + } + drawbars(); +} diff --git a/patch/nametag.h b/patch/nametag.h new file mode 100644 index 0000000..3e632be --- /dev/null +++ b/patch/nametag.h @@ -0,0 +1 @@ +static void nametag(const Arg *arg); |
