sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit c1443a028a857b3ed07f6f3cf1e522fc468e15e7
parent 56cf520cbf988ecd3c56fdc0dffbfa3177281b5c
Author: Ondrej Grover <ondrej.grover@gmail.com>
Date:   Sat,  7 Jun 2014 12:40:44 +0200

new dwm sub-patch: nametag-prepend

makes name "foo" given to tag 5 automatically "5:foo"

Diffstat:
Adwm.suckless.org/patches/dwm-6.1-nametag-prepend.diff | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdwm.suckless.org/patches/nametag.md | 4++++
2 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-6.1-nametag-prepend.diff b/dwm.suckless.org/patches/dwm-6.1-nametag-prepend.diff @@ -0,0 +1,71 @@ +diff --git a/config.def.h b/config.def.h +index 875885b..222745d 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -14,7 +14,10 @@ static const Bool showbar = True; /* False means no bar */ + static const Bool topbar = True; /* False means bottom bar */ + + /* tagging */ +-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; ++#define MAX_TAGNAME_LEN 14 /* excludes TAG_PREPEND */ ++#define TAG_PREPEND "%1i:" /* formatted as 2 chars */ ++#define MAX_TAGLEN 16 /* altogether */ ++static char tags[][MAX_TAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + + static const Rule rules[] = { + /* xprop(1): +@@ -79,6 +82,7 @@ static Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_n, nametag, {0} }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff --git a/dwm.c b/dwm.c +index 1bbb4b3..fefdd69 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -183,6 +183,7 @@ static void maprequest(XEvent *e); + static void monocle(Monitor *m); + static void motionnotify(XEvent *e); + static void movemouse(const Arg *arg); ++static void nametag(const Arg *arg); + static Client *nexttiled(Client *c); + static void pop(Client *); + static void propertynotify(XEvent *e); +@@ -1174,6 +1175,34 @@ movemouse(const Arg *arg) { + } + } + ++void ++nametag(const Arg *arg) { ++ char *p, name[MAX_TAGNAME_LEN]; ++ FILE *f; ++ int i; ++ ++ errno = 0; // popen(3p) says on failure it "may" set errno ++ if(!(f = popen("dmenu < /dev/null", "r"))) { ++ fprintf(stderr, "dwm: popen 'dmenu < /dev/null' failed%s%s\n", errno ? ": " : "", errno ? strerror(errno) : ""); ++ return; ++ } ++ if (!(p = fgets(name, MAX_TAGNAME_LEN, f)) && (i = errno) && ferror(f)) ++ fprintf(stderr, "dwm: fgets failed: %s\n", strerror(i)); ++ if (pclose(f) < 0) ++ fprintf(stderr, "dwm: pclose failed: %s\n", strerror(errno)); ++ if(!p) ++ return; ++ if((p = strchr(name, '\n'))) ++ *p = '\0'; ++ ++ for(i = 0; i < LENGTH(tags); i++) ++ if(selmon->tagset[selmon->seltags] & (1 << i)) { ++ sprintf(tags[i], TAG_PREPEND, i+1); ++ strcat(tags[i], name); ++ } ++ drawbars(); ++} ++ + Client * + nexttiled(Client *c) { + for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); diff --git a/dwm.suckless.org/patches/nametag.md b/dwm.suckless.org/patches/nametag.md @@ -6,13 +6,17 @@ Description This patch allows you to change the names of dwm's tags while it's running. By default there is a 16 byte limit on tag names, and it uses dmenu to prompt for tag names. The 6.1 patch is for the current tip (cdec9782a1789bd5c3a84772fd59abb9da288597). It works with 6.0 but you should add -D_POSIX_C_SOURCE=2 to CPPFLAGS or you will get implicit delcaration warnings for popen and pclose. +The `prepend` version prepends the tag name with a short string which is used as a format string for `sprintf` which gets the tag number as the argument. By default a tag name "foo" given to tag 5 will become tag "5:foo". + Download -------- * [dwm-6.1-nametag.diff](dwm-6.1-nametag.diff) (2.3k) (20131002) +* [dwm-6.1-nametag-prepend.diff](dwm-6.1-nametag-prepend.diff) (2525b) (20140607) * [dwm-5.7.2-nametag.diff](dwm-5.7.2-nametag.diff) (2.5k) (20091029) Author ------ * Evan Gates (emg) <[evan.gates@gmail.com](mailto:evan.gates@gmail.com)> +* prepend version by Ondřej Grover <ondrej dot grover at gmail dot com>