Skip to content

Instantly share code, notes, and snippets.

@chrismetcalf
Created May 18, 2011 15:35
Show Gist options
  • Save chrismetcalf/978820 to your computer and use it in GitHub Desktop.
Save chrismetcalf/978820 to your computer and use it in GitHub Desktop.
New version of nametag patch for DWM 5.8.2 (http://dwm.suckless.org/patches/nametag)
diff -up dwm-5.8.2/config.def.h dwm-5.8.2.patched/config.def.h
--- dwm-5.8.2/config.def.h 2010-06-04 06:39:15.000000000 -0400
+++ dwm-5.8.2.patched/config.def.h 2011-05-18 11:31:44.000000000 -0400
@@ -14,7 +14,8 @@ static const Bool showbar = Tr
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_TAGLEN 16
+static char tags[][MAX_TAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
@@ -71,6 +72,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)
Only in dwm-5.8.2.patched: config.h
Only in dwm-5.8.2.patched: config.mk.orig
Only in dwm-5.8.2.patched: config.mk.rej
Only in dwm-5.8.2.patched: dwm
diff -up dwm-5.8.2/dwm.1 dwm-5.8.2.patched/dwm.1
--- dwm-5.8.2/dwm.1 2010-06-04 06:39:15.000000000 -0400
+++ dwm-5.8.2.patched/dwm.1 2011-05-18 13:12:07.000000000 -0400
@@ -128,6 +128,9 @@ View all windows with any tag.
.B Mod1\-Control\-[1..n]
Add/remove all windows with nth tag to/from the view.
.TP
+.B Mod1\-n
+Rename the current tag
+.TP
.B Mod1\-Shift\-q
Quit dwm.
.SS Mouse commands
diff -up dwm-5.8.2/dwm.c dwm-5.8.2.patched/dwm.c
--- dwm-5.8.2/dwm.c 2010-06-04 06:39:15.000000000 -0400
+++ dwm-5.8.2.patched/dwm.c 2011-05-18 11:31:44.000000000 -0400
@@ -198,6 +198,7 @@ static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void movemouse(const Arg *arg);
+static void nametag(const Arg *arg);
static Client *nexttiled(Client *c);
static Monitor *ptrtomon(int x, int y);
static void propertynotify(XEvent *e);
@@ -1247,6 +1248,25 @@ movemouse(const Arg *arg) {
}
}
+void
+nametag(const Arg *arg) {
+ char *cp, name[MAX_TAGLEN];
+ FILE *fp;
+ int i;
+
+ if(!(fp = (FILE*)popen("dmenu -p tag", "r")))
+ fprintf(stderr, "dwm: Could not popen 'echo -n | dmenu'\n");
+ cp = fgets(name, MAX_TAGLEN, fp);
+ pclose(fp);
+ if(cp == NULL)
+ return;
+
+ for(i = 0; i < LENGTH(tags); i++)
+ if(selmon->tagset[selmon->seltags] & (1 << i))
+ memcpy(tags[i], name, MAX_TAGLEN);
+ drawbars();
+}
+
Client *
nexttiled(Client *c) {
for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
Only in dwm-5.8.2.patched: dwm.c.orig
Only in dwm-5.8.2.patched: dwm.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment