Commits

Thomas Dahms committed 136e4d8

nametag und ncol

Comments (0)

Files changed (4)

+^\.hg
+^\.mq
+syntax: glob
+status
+guards
+# HG changeset patch
+# Parent 0a1dabd9f1a364c65a74ea695413ebbe187ee08d
+
+diff -r 0a1dabd9f1a3 config.def.h
+--- a/config.def.h	Wed Oct 26 12:16:25 2011 +0100
++++ b/config.def.h	Thu Oct 27 08:53:49 2011 +0200
+@@ -14,7 +14,8 @@
+ 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 */
+@@ -74,6 +75,7 @@
+ 	{ 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 -r 0a1dabd9f1a3 config.mk
+--- a/config.mk	Wed Oct 26 12:16:25 2011 +0100
++++ b/config.mk	Thu Oct 27 08:53:49 2011 +0200
+@@ -19,7 +19,7 @@
+ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
+ 
+ # flags
+-CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
++CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+ #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
+ CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
+ #LDFLAGS = -g ${LIBS}
+diff -r 0a1dabd9f1a3 dwm.c
+--- a/dwm.c	Wed Oct 26 12:16:25 2011 +0100
++++ b/dwm.c	Thu Oct 27 08:53:49 2011 +0200
+@@ -199,6 +199,7 @@
+ 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 void pop(Client *);
+ static void propertynotify(XEvent *e);
+@@ -1263,6 +1264,25 @@
+ 	}
+ }
+ 
++void
++nametag(const Arg *arg) {
++	char *cp, name[MAX_TAGLEN];
++	FILE *fp;
++	int i;
++
++	if(!(fp = (FILE*)popen("echo -n | dmenu", "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);
+# HG changeset patch
+# Parent 483becdd9105603195d47a2b7f6fc778af5ead6d
+
+diff -r 483becdd9105 ncol.c
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/ncol.c	Thu Oct 27 08:56:54 2011 +0200
+@@ -0,0 +1,19 @@
++void
++ncol(Monitor *m) {
++	unsigned int i, n, mw, tw, th;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++
++	mw = (n > m->nmaster) ? m->ww * m->mfact / m->nmaster : m->ww / n;
++	th = (n > m->nmaster) ? m->wh / (n - m->nmaster) : 0;
++	tw = (n > m->nmaster) ? m->ww - mw * m->nmaster : 0;
++
++	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++		if(i < m->nmaster)
++			resize(c, m->wx + (i*mw), m->wy, mw - (2*c->bw), m->wh - (2*c->bw), False);
++		else
++			resize(c, m->wx + mw * m->nmaster, m->wy + ((i - m->nmaster)*th), tw - (2*c->bw), th - (2*c->bw), False);
++}
+nametag
+ncol