On 01.11.11, Connor Lane Smith wrote: > 2wm is very old and completely unsupported, so I doubt there are > patches like this. It would be awesome if there were a dwm 'stereo > patch', though.
I've tried 2wm some time ago, liked the concept but got fed up with its old code base. So I wrote a small dwm -> 2wm (d2wm) conversion patch. The patch simply changes toggle{tag,view}, so that they move the current client to the other tag / change the view to the other tag. Some additional lines in the patch overwrite the tagnames with the number of clients attached to the tag. The patch also changes some mouse and keybindings in config.def.h, most importantly Mod-{Shift-}Space for toggle{view,tag}, so that one can directly try it out. Bert
diff -rup dwm-5.9-orig/config.def.h dwm-5.9/config.def.h --- dwm-5.9-orig/config.def.h 2011-11-01 08:50:33.000000000 +0100 +++ dwm-5.9/config.def.h 2011-11-01 08:58:00.000000000 +0100 @@ -14,7 +14,7 @@ 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" }; +static const char *tags[] = { "1", "2" }; static const Rule rules[] = { /* class instance title tags mask isfloating monitor */ @@ -35,11 +35,6 @@ static const Layout layouts[] = { /* key definitions */ #define MODKEY Mod1Mask -#define TAGKEYS(KEY,TAG) \ - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } @@ -62,24 +57,14 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY|ShiftMask, XK_f, togglefloating, {0} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_space, toggleview, {0} }, + { MODKEY|ShiftMask, XK_space, toggletag, {0} }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) { MODKEY|ShiftMask, XK_q, quit, {0} }, }; @@ -94,9 +79,7 @@ static Button buttons[] = { { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + { ClkTagBar, 0, Button1, toggleview, {0} }, + { ClkTagBar, 0, Button3, toggletag, {0} }, }; diff -rup dwm-5.9-orig/dwm.c dwm-5.9/dwm.c --- dwm-5.9-orig/dwm.c 2011-11-01 08:50:33.000000000 +0100 +++ dwm-5.9/dwm.c 2011-11-01 08:54:09.000000000 +0100 @@ -247,7 +247,7 @@ static void zoom(const Arg *arg); /* variables */ static const char broken[] = "broken"; -static char stext[256]; +static char stext[256], tagname[3]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh, blw = 0; /* bar geometry */ @@ -434,7 +434,7 @@ buttonpress(XEvent *e) { if(ev->window == selmon->barwin) { i = x = 0; do { - x += TEXTW(tags[i]); + x += TEXTW(tagname); } while(ev->x >= x && ++i < LENGTH(tags)); if(i < LENGTH(tags)) { click = ClkTagBar; @@ -723,23 +723,26 @@ dirtomon(int dir) { void drawbar(Monitor *m) { - int x; + int nclients[LENGTH(tags)], x; unsigned int i, occ = 0, urg = 0; unsigned long *col; Client *c; + memset(nclients, 0, sizeof(nclients)); for(c = m->clients; c; c = c->next) { occ |= c->tags; if(c->isurgent) urg |= c->tags; + for(i = 0; i < LENGTH(tags); i++) + if(c->tags & 1 << i) + nclients[i]++; } dc.x = 0; for(i = 0; i < LENGTH(tags); i++) { - dc.w = TEXTW(tags[i]); + snprintf(tagname, sizeof(tagname), "%02d", nclients[i] % 100); + dc.w = TEXTW(tagname); col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm; - drawtext(tags[i], col, urg & 1 << i); - drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i, - occ & 1 << i, urg & 1 << i, col); + drawtext(tagname, col, urg & 1 << i); dc.x += dc.w; } dc.w = blw = TEXTW(m->ltsymbol); @@ -1185,8 +1188,6 @@ monocle(Monitor *m) { for(c = m->clients; c; c = c->next) if(ISVISIBLE(c)) n++; - if(n > 0) /* override layout symbol */ - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False); } @@ -1690,25 +1691,20 @@ togglefloating(const Arg *arg) { void toggletag(const Arg *arg) { - unsigned int newtags; - - if(!selmon->sel) - return; - newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); - if(newtags) { - selmon->sel->tags = newtags; - arrange(selmon); + /* d2wm: move current client to other tag */ + Arg a; + if (selmon->sel) { + a.ui = selmon->sel->tags ^ 3; + tag(&a); } } void toggleview(const Arg *arg) { - unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); - - if(newtagset) { - selmon->tagset[selmon->seltags] = newtagset; - arrange(selmon); - } + /* d2wm: switch to other tag */ + Arg a; + a.ui = selmon->tagset[selmon->seltags] ^ 3; + view(&a); } void