You are not logged in.
I was wondering if someone could give me a hand with this pertag variant. portix originally posted it here.
Basically it sets an initial layout for each tag, which is something I'm quite keen on. I hand patched it and it compiles fine, unfortunately it doesn't really work - the initlayouts don't correspond to the layout rules (it seems rather random, in fact).
Is there something obvious that I am missing (no C skills at all - that's why I'm asking)?
diff -up dwm-5.7.2.orig/config.def.h dwm-5.7.2/config.def.h
--- dwm-5.7.2.orig/config.def.h 2010-02-12 17:29:34.000000000 +0100
+++ dwm-5.7.2/config.def.h 2010-02-12 18:29:36.000000000 +0100
@@ -16,6 +16,9 @@ static const Bool topbar = Tr
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+/* initial layouts */
+static const int initlayouts[] = { 0, 0, 1, 0, 1, 0, 1, 2, 0, 0 };
+
static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, True, -1 },
Nur in dwm-5.7.2: config.h.
diff -up dwm-5.7.2.orig/dwm.c dwm-5.7.2/dwm.c
--- dwm-5.7.2.orig/dwm.c 2010-02-12 17:29:34.000000000 +0100
+++ dwm-5.7.2/dwm.c 2010-02-12 18:28:53.000000000 +0100
@@ -120,26 +120,6 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
-struct Monitor {
- char ltsymbol[16];
- float mfact;
- int num;
- int by; /* bar geometry */
- int mx, my, mw, mh; /* screen size */
- int wx, wy, ww, wh; /* window area */
- unsigned int seltags;
- unsigned int sellt;
- unsigned int tagset[2];
- Bool showbar;
- Bool topbar;
- Client *clients;
- Client *sel;
- Client *stack;
- Monitor *next;
- Window barwin;
- const Layout *lt[2];
-};
-
typedef struct {
const char *class;
const char *instance;
@@ -273,6 +253,31 @@ static Window root;
/* configuration, allows nested code to access above variables */
#include "config.h"
+struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+ int num;
+ int by; /* bar geometry */
+ int mx, my, mw, mh; /* screen size */
+ int wx, wy, ww, wh; /* window area */
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
+ Bool showbar;
+ Bool topbar;
+ Client *clients;
+ Client *sel;
+ Client *stack;
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
+ int curtag;
+ int prevtag;
+ const Layout *lts[LENGTH(tags) + 1];
+ double mfacts[LENGTH(tags) + 1];
+ Bool showbars[LENGTH(tags) + 1];
+};
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -615,7 +620,7 @@ createmon(void) {
m->topbar = topbar;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ strncpy(m->ltsymbol, initlayouts[1] && initlayouts[1] < LENGTH(layouts) ? layouts[initlayouts[1]].symbol : layouts[0].symbol, sizeof m->ltsymbol);
return m;
}
@@ -1450,7 +1455,7 @@ setlayout(const Arg *arg) {
if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if(arg && arg->v)
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if(selmon->sel)
arrange(selmon);
@@ -1468,13 +1473,15 @@ setmfact(const Arg *arg) {
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if(f < 0.1 || f > 0.9)
return;
- selmon->mfact = f;
+ selmon->mfact = selmon->mfacts[selmon->curtag] = f;
arrange(selmon);
}
void
setup(void) {
XSetWindowAttributes wa;
+ Monitor *m;
+ unsigned int i;
/* clean up any zombies immediately */
sigchld(0);
@@ -1509,7 +1516,27 @@ setup(void) {
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ /* init tags */
+ for(m = mons; m; m = m->next)
+ m->curtag = m->prevtag = 1;
+ /* init mfacts */
+ for(m = mons; m; m = m->next) {
+ for(i=0; i < LENGTH(tags) + 1 ; i++) {
+ m->mfacts[i] = m->mfact;
+ }
+ }
+ /* init layouts */
+ for(m = mons; m; m = m->next) {
+ for(i=0; i < LENGTH(tags) + 1; i++) {
+ m->lts[i] = initlayouts[i] && initlayouts[i] < LENGTH(layouts) ? &layouts[initlayouts[i]] : &layouts[0];
+ }
+ }
/* init bars */
+ for(m = mons; m; m = m->next) {
+ for(i=0; i < LENGTH(tags) + 1; i++) {
+ m->showbars[i] = m->showbar;
+ }
+ }
updatebars();
updatestatus();
/* EWMH support per view */
@@ -1620,7 +1647,7 @@ tile(Monitor *m) {
void
togglebar(const Arg *arg) {
- selmon->showbar = !selmon->showbar;
+ selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1640,12 +1667,27 @@ togglefloating(const Arg *arg) {
void
toggletag(const Arg *arg) {
unsigned int newtags;
+ unsigned int i;
if(!selmon->sel)
return;
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if(newtags) {
selmon->sel->tags = newtags;
+ if(newtags == ~0) {
+ selmon->prevtag = selmon->curtag;
+ selmon->curtag = 0;
+ }
+ if(!(newtags & 1 << (selmon->curtag - 1))) {
+ selmon->prevtag = selmon->curtag;
+ for (i=0; !(newtags & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ selmon->sel->tags = newtags;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if (selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
arrange(selmon);
}
}
@@ -1912,11 +1954,29 @@ updatewmhints(Client *c) {
void
view(const Arg *arg) {
+ unsigned int i;
+
if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
- if(arg->ui & TAGMASK)
+ if(arg->ui & TAGMASK) {
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->prevtag = selmon->curtag;
+ if(arg->ui == ~0)
+ selmon->curtag = 0;
+ else {
+ for (i=0; !(arg->ui & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ } else {
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ selmon->curtag^= selmon->prevtag;
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ }
+ selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if(selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
arrange(selmon);
}
# edit: changes from standard pertag.diff are at lines 8-9, 81-82 and 128.
Last edited by jasonwryan (2010-03-30 06:46:24)
Offline
The first Element in initlayouts is the layout for tag 0, the second for the first tag and so on, but it only works, if the layout for the first tag is the default layout. Here is a patch, that fixes this issue http://bitbucket.org/portix/dwm/src/tip/dwm-portix.diff.
Offline
I've been looking for a patch that can make dwm handle dual monitors like Xmonad does (where a tag can be on one and only one monitor). Anyone ever seen something like that? I'm pretty close to just banging my own patch out...but hopefully someone has already done it.
Last edited by giir (2010-03-30 17:56:06)
dub dromic - dotfiles!
Offline
The first Element in initlayouts is the layout for tag 0, the second for the first tag and so on, but it only works, if the layout for the first tag is the default layout. Here is a patch, that fixes this issue http://bitbucket.org/portix/dwm/src/tip/dwm-portix.diff.
Thanks portix. I went through your diff, weeded out all of the nmaster stuff and just patched in the lines that diff from standard pertag - and I get the same result, compiling but not respecting the initlayouts. I suspect I am missing a line or two (I probably mistook them as related to nmaster or your dual monitor).
Lines I patched from your diff in dwm.c: 290-295, 398 420-421.
Offline
I was wondering if someone could give me a hand with this pertag variant. portix originally posted it here.
Basically it sets an initial layout for each tag, which is something I'm quite keen on. I hand patched it and it compiles fine, unfortunately it doesn't really work - the initlayouts don't correspond to the layout rules (it seems rather random, in fact).
Is there something obvious that I am missing (no C skills at all - that's why I'm asking)?
diff -up dwm-5.7.2.orig/config.def.h dwm-5.7.2/config.def.h --- dwm-5.7.2.orig/config.def.h 2010-02-12 17:29:34.000000000 +0100 +++ dwm-5.7.2/config.def.h 2010-02-12 18:29:36.000000000 +0100 @@ -16,6 +16,9 @@ static const Bool topbar = Tr /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +/* initial layouts */ +static const int initlayouts[] = { 0, 0, 1, 0, 1, 0, 1, 2, 0, 0 }; + static const Rule rules[] = { /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, True, -1 }, Nur in dwm-5.7.2: config.h. diff -up dwm-5.7.2.orig/dwm.c dwm-5.7.2/dwm.c --- dwm-5.7.2.orig/dwm.c 2010-02-12 17:29:34.000000000 +0100 +++ dwm-5.7.2/dwm.c 2010-02-12 18:28:53.000000000 +0100 @@ -120,26 +120,6 @@ typedef struct { void (*arrange)(Monitor *); } Layout; -struct Monitor { - char ltsymbol[16]; - float mfact; - int num; - int by; /* bar geometry */ - int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ - unsigned int seltags; - unsigned int sellt; - unsigned int tagset[2]; - Bool showbar; - Bool topbar; - Client *clients; - Client *sel; - Client *stack; - Monitor *next; - Window barwin; - const Layout *lt[2]; -}; - typedef struct { const char *class; const char *instance; @@ -273,6 +253,31 @@ static Window root; /* configuration, allows nested code to access above variables */ #include "config.h" +struct Monitor { + char ltsymbol[16]; + float mfact; + int num; + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; + Bool showbar; + Bool topbar; + Client *clients; + Client *sel; + Client *stack; + Monitor *next; + Window barwin; + const Layout *lt[2]; + int curtag; + int prevtag; + const Layout *lts[LENGTH(tags) + 1]; + double mfacts[LENGTH(tags) + 1]; + Bool showbars[LENGTH(tags) + 1]; +}; + /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -615,7 +620,7 @@ createmon(void) { m->topbar = topbar; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + strncpy(m->ltsymbol, initlayouts[1] && initlayouts[1] < LENGTH(layouts) ? layouts[initlayouts[1]].symbol : layouts[0].symbol, sizeof m->ltsymbol); return m; } @@ -1450,7 +1455,7 @@ setlayout(const Arg *arg) { if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) selmon->sellt ^= 1; if(arg && arg->v) - selmon->lt[selmon->sellt] = (Layout *)arg->v; + selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v; strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if(selmon->sel) arrange(selmon); @@ -1468,13 +1473,15 @@ setmfact(const Arg *arg) { f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; if(f < 0.1 || f > 0.9) return; - selmon->mfact = f; + selmon->mfact = selmon->mfacts[selmon->curtag] = f; arrange(selmon); } void setup(void) { XSetWindowAttributes wa; + Monitor *m; + unsigned int i; /* clean up any zombies immediately */ sigchld(0); @@ -1509,7 +1516,27 @@ setup(void) { XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) XSetFont(dpy, dc.gc, dc.font.xfont->fid); + /* init tags */ + for(m = mons; m; m = m->next) + m->curtag = m->prevtag = 1; + /* init mfacts */ + for(m = mons; m; m = m->next) { + for(i=0; i < LENGTH(tags) + 1 ; i++) { + m->mfacts[i] = m->mfact; + } + } + /* init layouts */ + for(m = mons; m; m = m->next) { + for(i=0; i < LENGTH(tags) + 1; i++) { + m->lts[i] = initlayouts[i] && initlayouts[i] < LENGTH(layouts) ? &layouts[initlayouts[i]] : &layouts[0]; + } + } /* init bars */ + for(m = mons; m; m = m->next) { + for(i=0; i < LENGTH(tags) + 1; i++) { + m->showbars[i] = m->showbar; + } + } updatebars(); updatestatus(); /* EWMH support per view */ @@ -1620,7 +1647,7 @@ tile(Monitor *m) { void togglebar(const Arg *arg) { - selmon->showbar = !selmon->showbar; + selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar; updatebarpos(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); arrange(selmon); @@ -1640,12 +1667,27 @@ togglefloating(const Arg *arg) { void toggletag(const Arg *arg) { unsigned int newtags; + unsigned int i; if(!selmon->sel) return; newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); if(newtags) { selmon->sel->tags = newtags; + if(newtags == ~0) { + selmon->prevtag = selmon->curtag; + selmon->curtag = 0; + } + if(!(newtags & 1 << (selmon->curtag - 1))) { + selmon->prevtag = selmon->curtag; + for (i=0; !(newtags & 1 << i); i++); + selmon->curtag = i + 1; + } + selmon->sel->tags = newtags; + selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag]; + selmon->mfact = selmon->mfacts[selmon->curtag]; + if (selmon->showbar != selmon->showbars[selmon->curtag]) + togglebar(NULL); arrange(selmon); } } @@ -1912,11 +1954,29 @@ updatewmhints(Client *c) { void view(const Arg *arg) { + unsigned int i; + if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; selmon->seltags ^= 1; /* toggle sel tagset */ - if(arg->ui & TAGMASK) + if(arg->ui & TAGMASK) { selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + selmon->prevtag = selmon->curtag; + if(arg->ui == ~0) + selmon->curtag = 0; + else { + for (i=0; !(arg->ui & 1 << i); i++); + selmon->curtag = i + 1; + } + } else { + selmon->prevtag= selmon->curtag ^ selmon->prevtag; + selmon->curtag^= selmon->prevtag; + selmon->prevtag= selmon->curtag ^ selmon->prevtag; + } + selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag]; + selmon->mfact = selmon->mfacts[selmon->curtag]; + if(selmon->showbar != selmon->showbars[selmon->curtag]) + togglebar(NULL); arrange(selmon); }
# edit: changes from standard pertag.diff are at lines 8-9, 81-82 and 128.
EDIT: WARNING If you use mine your other patches may break as I make no attempt to maintain any backward compatibility with how vanilla dwm handles tags, layouts, mfact, or nmaster. Your 3rd party arrangers may break but my changes are pretty minor. My approach to pertag is a bit different as the patch on the dwm site kinda sucks too.
I have a patch for that (this patch is merged with nmaster).
pertag2.diff
This is how I config it.
/* layout(s) */
#include "nbstack.c"
static const Layout layouts[] = {
/* symbol add gaps arrange function */
{ "=2]", True, ntile },
{ "T2T", True, nbstack },
{ "[M]", True, monocle },
{ "><>", False, NULL }, /* no layout function means floating behavior */
};
/* tagging */
static const Tag tags[] = {
/* name layout mfact nmaster */
{ "term", &layouts[1], -1, -1 },
{ "dev", &layouts[0], -1, -1 },
{ "web", &layouts[2], -1, 1 },
{ "chat", &layouts[0], 0.70, -1 },
{ "virt", &layouts[2], -1, -1 },
{ "misc", &layouts[0], -1, -1 },
};
Last edited by simongmzlj (2010-03-30 22:26:11)
Offline
Thanks Simon. I had seen your patch, but I don't require nmaster functionality, so wasn't keen to use the whole patch and -as with portix's patch- wasn't able to successfully disentangle only the pertag chunks from it...
Offline
Thanks Simon. I had seen your patch, but I don't require nmaster functionality, so wasn't keen to use the whole patch and -as with portix's patch- wasn't able to successfully disentangle only the pertag chunks from it...
Patch it against vanilla dwm.c, restore ntile to tile, remove nmasters/nmaster, make new patch.
--- a/dwm..c 2010-03-30 19:53:14.530198754 -0400
+++ b/dwm.c 2010-03-30 19:54:18.110207383 -0400
@@ -122,7 +122,6 @@
struct Monitor {
char ltsymbol[16];
- float mfact;
int num;
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
@@ -138,9 +137,19 @@
Monitor *next;
Window barwin;
const Layout *lt[2];
+ int curtag;
+ int prevtag;
+ const Layout **lts;
+ double *mfacts;
};
typedef struct {
+ const char *name;
+ const Layout *layout;
+ float mfact;
+} Tag;
+
+typedef struct {
const char *class;
const char *instance;
const char *title;
@@ -430,7 +439,7 @@
if(ev->window == selmon->barwin) {
i = x = 0;
do {
- x += TEXTW(tags[i]);
+ x += TEXTW(tags[i].name);
} while(ev->x >= x && ++i < LENGTH(tags));
if(i < LENGTH(tags)) {
click = ClkTagBar;
@@ -505,6 +514,8 @@
}
XUnmapWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->barwin);
+ free(mon->mfacts);
+ free(mon->lts);
free(mon);
}
@@ -603,19 +614,29 @@
XSync(dpy, False);
}
+/* TODO Check how many times createmon is called */
Monitor *
createmon(void) {
Monitor *m;
+ int i, numtags = LENGTH(tags) + 1;
if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+ if(!(m->mfacts = calloc(sizeof(double), numtags)))
+ die("fatal: could not malloc() %u bytes\n", sizeof(double) * numtags);
+ if(!(m->lts = calloc(sizeof(Layout *), numtags)))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Layout *) * numtags);
m->tagset[0] = m->tagset[1] = 1;
- m->mfact = mfact;
m->showbar = showbar;
m->topbar = topbar;
- m->lt[0] = &layouts[0];
+ m->curtag = m->prevtag = 1;
+ for(i = 1; i < numtags; i++) {
+ m->mfacts[i] = tags[i - 1].mfact < 0 ? mfact : tags[i - 1].mfact;
+ m->lts[i] = tags[i - 1].layout;
+ }
+ m->lt[0] = m->lts[m->curtag];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ strncpy(m->ltsymbol, m->lt[0]->symbol, sizeof m->ltsymbol);
return m;
}
@@ -690,9 +711,9 @@
}
dc.x = 0;
for(i = 0; i < LENGTH(tags); i++) {
- dc.w = TEXTW(tags[i]);
+ dc.w = TEXTW(tags[i].name);
col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
- drawtext(tags[i], col, urg & 1 << i);
+ drawtext(tags[i].name, col, urg & 1 << i);
drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
occ & 1 << i, urg & 1 << i, col);
dc.x += dc.w;
@@ -1450,7 +1471,7 @@
if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if(arg && arg->v)
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if(selmon->sel)
arrange(selmon);
@@ -1465,10 +1486,10 @@
if(!arg || !selmon->lt[selmon->sellt]->arrange)
return;
- f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ f = arg->f < 1.0 ? arg->f + selmon->mfacts[selmon->curtag] : arg->f - 1.0;
if(f < 0.1 || f > 0.9)
return;
- selmon->mfact = f;
+ selmon->mfacts[selmon->curtag] = f;
arrange(selmon);
}
@@ -1640,12 +1661,24 @@
void
toggletag(const Arg *arg) {
unsigned int newtags;
+ unsigned int i;
if(!selmon->sel)
return;
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if(newtags) {
selmon->sel->tags = newtags;
+ if(newtags == ~0) {
+ selmon->prevtag = selmon->curtag;
+ selmon->curtag = 0;
+ }
+ if(!(newtags & 1 << (selmon->curtag - 1))) {
+ selmon->prevtag = selmon->curtag;
+ for (i=0; !(newtags & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ selmon->sel->tags = newtags;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
arrange(selmon);
}
}
@@ -1912,11 +1945,26 @@
void
view(const Arg *arg) {
+ unsigned int i;
+
if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
- if(arg->ui & TAGMASK)
+ if(arg->ui & TAGMASK) {
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->prevtag = selmon->curtag;
+ if(arg->ui == ~0)
+ selmon->curtag = 0;
+ else {
+ for (i=0; !(arg->ui & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ } else {
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ selmon->curtag^= selmon->prevtag;
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ }
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
arrange(selmon);
}
Offline
@ jasonwryan: pertag patch with initlayouts for vanilla dwm:
diff -up dwm-5.7.2.orig//config.h dwm-5.7.2/config.h
--- dwm-5.7.2.orig//config.h 2010-03-31 12:32:53.000000000 +0200
+++ dwm-5.7.2/config.h 2010-03-31 12:32:25.000000000 +0200
@@ -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" };
+static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const int initlayouts[] = { 0, 1, 0, 1, 1, 1, 2, 0, 2, 1 };
static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
diff -up dwm-5.7.2.orig//dwm.c dwm-5.7.2/dwm.c
--- dwm-5.7.2.orig//dwm.c 2010-03-31 12:17:10.000000000 +0200
+++ dwm-5.7.2/dwm.c 2010-03-31 12:27:32.000000000 +0200
@@ -120,26 +120,6 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
-struct Monitor {
- char ltsymbol[16];
- float mfact;
- int num;
- int by; /* bar geometry */
- int mx, my, mw, mh; /* screen size */
- int wx, wy, ww, wh; /* window area */
- unsigned int seltags;
- unsigned int sellt;
- unsigned int tagset[2];
- Bool showbar;
- Bool topbar;
- Client *clients;
- Client *sel;
- Client *stack;
- Monitor *next;
- Window barwin;
- const Layout *lt[2];
-};
-
typedef struct {
const char *class;
const char *instance;
@@ -273,6 +253,31 @@ static Window root;
/* configuration, allows nested code to access above variables */
#include "config.h"
+struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+ int num;
+ int by; /* bar geometry */
+ int mx, my, mw, mh; /* screen size */
+ int wx, wy, ww, wh; /* window area */
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
+ Bool showbar;
+ Bool topbar;
+ Client *clients;
+ Client *sel;
+ Client *stack;
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
+ int curtag;
+ int prevtag;
+ const Layout *lts[LENGTH(tags) + 1];
+ double mfacts[LENGTH(tags) + 1];
+ Bool showbars[LENGTH(tags) + 1];
+};
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -613,9 +618,9 @@ createmon(void) {
m->mfact = mfact;
m->showbar = showbar;
m->topbar = topbar;
- m->lt[0] = &layouts[0];
+ m->lt[0] = &layouts[initlayouts[1]] && initlayouts[1] < LENGTH(layouts) ? &layouts[initlayouts[1]] : &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ strncpy(m->ltsymbol, initlayouts[1] && initlayouts[1] < LENGTH(layouts) ? layouts[initlayouts[1]].symbol : layouts[0].symbol, sizeof m->ltsymbol);
return m;
}
@@ -1450,7 +1455,7 @@ setlayout(const Arg *arg) {
if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if(arg && arg->v)
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if(selmon->sel)
arrange(selmon);
@@ -1468,13 +1473,15 @@ setmfact(const Arg *arg) {
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if(f < 0.1 || f > 0.9)
return;
- selmon->mfact = f;
+ selmon->mfact = selmon->mfacts[selmon->curtag] = f;
arrange(selmon);
}
void
setup(void) {
XSetWindowAttributes wa;
+ Monitor *m;
+ unsigned int i;
/* clean up any zombies immediately */
sigchld(0);
@@ -1509,7 +1516,27 @@ setup(void) {
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ /* init tags */
+ for(m = mons; m; m = m->next)
+ m->curtag = m->prevtag = 1;
+ /* init mfacts */
+ for(m = mons; m; m = m->next) {
+ for(i=0; i < LENGTH(tags) + 1 ; i++) {
+ m->mfacts[i] = m->mfact;
+ }
+ }
+ /* init layouts */
+ for(m = mons; m; m = m->next) {
+ for(i=0; i < LENGTH(tags) + 1; i++) {
+ m->lts[i] = initlayouts[i] && initlayouts[i] < LENGTH(layouts) ? &layouts[initlayouts[i]] : &layouts[0];
+ }
+ }
/* init bars */
+ for(m = mons; m; m = m->next) {
+ for(i=0; i < LENGTH(tags) + 1; i++) {
+ m->showbars[i] = m->showbar;
+ }
+ }
updatebars();
updatestatus();
/* EWMH support per view */
@@ -1620,7 +1647,7 @@ tile(Monitor *m) {
void
togglebar(const Arg *arg) {
- selmon->showbar = !selmon->showbar;
+ selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1640,12 +1667,27 @@ togglefloating(const Arg *arg) {
void
toggletag(const Arg *arg) {
unsigned int newtags;
+ unsigned int i;
if(!selmon->sel)
return;
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if(newtags) {
selmon->sel->tags = newtags;
+ if(newtags == ~0) {
+ selmon->prevtag = selmon->curtag;
+ selmon->curtag = 0;
+ }
+ if(!(newtags & 1 << (selmon->curtag - 1))) {
+ selmon->prevtag = selmon->curtag;
+ for (i=0; !(newtags & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ selmon->sel->tags = newtags;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if (selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
arrange(selmon);
}
}
@@ -1912,11 +1954,29 @@ updatewmhints(Client *c) {
void
view(const Arg *arg) {
+ unsigned int i;
+
if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
- if(arg->ui & TAGMASK)
+ if(arg->ui & TAGMASK) {
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->prevtag = selmon->curtag;
+ if(arg->ui == ~0)
+ selmon->curtag = 0;
+ else {
+ for (i=0; !(arg->ui & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ } else {
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ selmon->curtag^= selmon->prevtag;
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ }
+ selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if(selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
arrange(selmon);
}
Offline
@ jasonwryan: pertag patch with initlayouts for vanilla dwm:
diff -up dwm-5.7.2.orig//config.h dwm-5.7.2/config.h --- dwm-5.7.2.orig//config.h 2010-03-31 12:32:53.000000000 +0200 +++ dwm-5.7.2/config.h 2010-03-31 12:32:25.000000000 +0200 @@ -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" }; +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const int initlayouts[] = { 0, 1, 0, 1, 1, 1, 2, 0, 2, 1 }; static const Rule rules[] = { /* class instance title tags mask isfloating monitor */ diff -up dwm-5.7.2.orig//dwm.c dwm-5.7.2/dwm.c --- dwm-5.7.2.orig//dwm.c 2010-03-31 12:17:10.000000000 +0200 +++ dwm-5.7.2/dwm.c 2010-03-31 12:27:32.000000000 +0200 @@ -120,26 +120,6 @@ typedef struct { void (*arrange)(Monitor *); } Layout; -struct Monitor { - char ltsymbol[16]; - float mfact; - int num; - int by; /* bar geometry */ - int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ - unsigned int seltags; - unsigned int sellt; - unsigned int tagset[2]; - Bool showbar; - Bool topbar; - Client *clients; - Client *sel; - Client *stack; - Monitor *next; - Window barwin; - const Layout *lt[2]; -}; - typedef struct { const char *class; const char *instance; @@ -273,6 +253,31 @@ static Window root; /* configuration, allows nested code to access above variables */ #include "config.h" +struct Monitor { + char ltsymbol[16]; + float mfact; + int num; + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; + Bool showbar; + Bool topbar; + Client *clients; + Client *sel; + Client *stack; + Monitor *next; + Window barwin; + const Layout *lt[2]; + int curtag; + int prevtag; + const Layout *lts[LENGTH(tags) + 1]; + double mfacts[LENGTH(tags) + 1]; + Bool showbars[LENGTH(tags) + 1]; +}; + /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -613,9 +618,9 @@ createmon(void) { m->mfact = mfact; m->showbar = showbar; m->topbar = topbar; - m->lt[0] = &layouts[0]; + m->lt[0] = &layouts[initlayouts[1]] && initlayouts[1] < LENGTH(layouts) ? &layouts[initlayouts[1]] : &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + strncpy(m->ltsymbol, initlayouts[1] && initlayouts[1] < LENGTH(layouts) ? layouts[initlayouts[1]].symbol : layouts[0].symbol, sizeof m->ltsymbol); return m; } @@ -1450,7 +1455,7 @@ setlayout(const Arg *arg) { if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) selmon->sellt ^= 1; if(arg && arg->v) - selmon->lt[selmon->sellt] = (Layout *)arg->v; + selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v; strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if(selmon->sel) arrange(selmon); @@ -1468,13 +1473,15 @@ setmfact(const Arg *arg) { f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; if(f < 0.1 || f > 0.9) return; - selmon->mfact = f; + selmon->mfact = selmon->mfacts[selmon->curtag] = f; arrange(selmon); } void setup(void) { XSetWindowAttributes wa; + Monitor *m; + unsigned int i; /* clean up any zombies immediately */ sigchld(0); @@ -1509,7 +1516,27 @@ setup(void) { XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) XSetFont(dpy, dc.gc, dc.font.xfont->fid); + /* init tags */ + for(m = mons; m; m = m->next) + m->curtag = m->prevtag = 1; + /* init mfacts */ + for(m = mons; m; m = m->next) { + for(i=0; i < LENGTH(tags) + 1 ; i++) { + m->mfacts[i] = m->mfact; + } + } + /* init layouts */ + for(m = mons; m; m = m->next) { + for(i=0; i < LENGTH(tags) + 1; i++) { + m->lts[i] = initlayouts[i] && initlayouts[i] < LENGTH(layouts) ? &layouts[initlayouts[i]] : &layouts[0]; + } + } /* init bars */ + for(m = mons; m; m = m->next) { + for(i=0; i < LENGTH(tags) + 1; i++) { + m->showbars[i] = m->showbar; + } + } updatebars(); updatestatus(); /* EWMH support per view */ @@ -1620,7 +1647,7 @@ tile(Monitor *m) { void togglebar(const Arg *arg) { - selmon->showbar = !selmon->showbar; + selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar; updatebarpos(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); arrange(selmon); @@ -1640,12 +1667,27 @@ togglefloating(const Arg *arg) { void toggletag(const Arg *arg) { unsigned int newtags; + unsigned int i; if(!selmon->sel) return; newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); if(newtags) { selmon->sel->tags = newtags; + if(newtags == ~0) { + selmon->prevtag = selmon->curtag; + selmon->curtag = 0; + } + if(!(newtags & 1 << (selmon->curtag - 1))) { + selmon->prevtag = selmon->curtag; + for (i=0; !(newtags & 1 << i); i++); + selmon->curtag = i + 1; + } + selmon->sel->tags = newtags; + selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag]; + selmon->mfact = selmon->mfacts[selmon->curtag]; + if (selmon->showbar != selmon->showbars[selmon->curtag]) + togglebar(NULL); arrange(selmon); } } @@ -1912,11 +1954,29 @@ updatewmhints(Client *c) { void view(const Arg *arg) { + unsigned int i; + if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; selmon->seltags ^= 1; /* toggle sel tagset */ - if(arg->ui & TAGMASK) + if(arg->ui & TAGMASK) { selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + selmon->prevtag = selmon->curtag; + if(arg->ui == ~0) + selmon->curtag = 0; + else { + for (i=0; !(arg->ui & 1 << i); i++); + selmon->curtag = i + 1; + } + } else { + selmon->prevtag= selmon->curtag ^ selmon->prevtag; + selmon->curtag^= selmon->prevtag; + selmon->prevtag= selmon->curtag ^ selmon->prevtag; + } + selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag]; + selmon->mfact = selmon->mfacts[selmon->curtag]; + if(selmon->showbar != selmon->showbars[selmon->curtag]) + togglebar(NULL); arrange(selmon); }
The issue with moving the Monitor struct to below the #include "config.h" line is that it prevents you from including code like layouts directly in the config.h file, which is something I take advantage of. I understand why you do it, but you end up with many linking errors unless you put everything in dwm.c. However, in order to maintain the location of the Monitor struct you have to allocate the pertag values dynamically at runtime.
Offline
@ jasonwryan: pertag patch with initlayouts for vanilla dwm:
--snip /--
Thanks portix: that works nicely (once I had realised to add a 0 layout)...
Offline
Well, I'm new to dwm since my xmonad died after an update. It seems like bstack and nmaster aren't patching correctly. Every time I try including them, it fails while compiling. Other than that.. DWM rules.
Offline
<not actual anymore>
Last edited by cf8 (2010-09-21 08:48:39)
Offline
I created a regular patch file for push.c. I didn't bother updating config.h though:
dwm-5.7.2-push.patch
--- dwm-5.7.2.orig/dwm.c 2009-09-27 12:20:23.000000000 -0700
+++ dwm-5.7.2.patched/dwm.c.new 2010-04-03 11:18:50.820733064 -0700
@@ -198,6 +198,8 @@
static Client *nexttiled(Client *c);
static Monitor *ptrtomon(int x, int y);
static void propertynotify(XEvent *e);
+static void pushup(const Arg *arg);
+static void pushdown(const Arg *arg);
static void quit(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, Bool interact);
static void resizemouse(const Arg *arg);
@@ -2016,3 +2018,62 @@
XCloseDisplay(dpy);
return 0;
}
+
+static Client *
+prevtiled(Client *c) {
+ Client *p, *r;
+
+ for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
+ if(!p->isfloating && ISVISIBLE(p))
+ r = p;
+ return r;
+}
+
+static void
+pushup(const Arg *arg) {
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if(!sel || sel->isfloating)
+ return;
+ if((c = prevtiled(sel))) {
+ /* attach before c */
+ detach(sel);
+ sel->next = c;
+ if(selmon->clients == c)
+ selmon->clients = sel;
+ else {
+ for(c = selmon->clients; c->next != sel->next; c = c->next);
+ c->next = sel;
+ }
+ } else {
+ /* move to the end */
+ for(c = sel; c->next; c = c->next);
+ detach(sel);
+ sel->next = NULL;
+ c->next = sel;
+ }
+ focus(sel);
+ arrange(selmon);
+}
+
+static void
+pushdown(const Arg *arg) {
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if(!sel || sel->isfloating)
+ return;
+ if((c = nexttiled(sel->next))) {
+ /* attach after c */
+ detach(sel);
+ sel->next = c->next;
+ c->next = sel;
+ } else {
+ /* move to the front */
+ detach(sel);
+ attach(sel);
+ }
+ focus(sel);
+ arrange(selmon);
+}
The lines I use to control it in config.h are:
{ MODKEY|ShiftMask, XK_j, pushdown, {0} },
{ MODKEY|ShiftMask, XK_k, pushup, {0} },
Offline
This maybe is a stupid question, but how do i go about MODKEY+Space cycling through ALL of my layouts, just like in xmonad ?
Offline
You want the cycle patch: http://github.com/simongmzlj/dwm/blob/master/cycle.c
Offline
Thanks
Offline
Sorry for the double post, but i just created a patch that resolves keymapping problems using azerty keyboard layouts within dwm, so the MOD+[1-9] used to change tags is restored.
you can call it dwm_azerty.diff or azerty.diff, and that would be kind if you could put this on github
Offline
Sorry for bumping an old thread here, but has anyone come up with away to have attachaside be the default for new windows? It works ok the way it is, but DWM switches back to the default attaching-as-master silliness every time you switch tags, which is annoying.
Offline
Paul-S wrote:Cool patches, lolilolicon how did you make the scratchpad, one of the few things I miss from XMonad.
Cheers
Paul-S... .... ...
The idea is simple:
The Scratchpad stays in its own tag (6 here)
I toggle it by toggleview this tag (MODKEY + x)
But due to this simple disign:
You have to press MODKEY + Control + x to launch it first;
It won't auto focus.
... ... ...
It's been a long time. Today I looked into dwm.c a bit, then cooked up this improved scratchpad for dwm, i.e. a normal scratchpad without the obvious flaws: when you press the key combo for it, whether already launched or not, the scratchpad will come up and get focus.
If you look at the code, you can tell it's based on my original idea ("toggleview").
So here's the patch for 5.8.2
https://github.com/lolilolicon/dwm/blob … chpad.diff
You'll need to edit your config.h like this:
static const char scratchpadname[] = "Scratchpad";
static const char *scratchpadcmd[] = { "urxvt", "-name", scratchpadname, "-geometry", "80x20", NULL };
static Key keys[] = {
{ MODKEY, XK_x, togglescratch, {.v = scratchpadcmd} },
}
Be sure to set scratchpadname to a unique value since my patch use this to determine if the client is a scratchpad.
There might be bugs in it. Feedback appreciated!
Edit:
With the former patch, when you have the scratchpad brought up, then press Mod+2 ("view" tag 2), the pad will be gone. This may or may not be what you want.
Here's an alternative patch which lets the scratchpad stay in view when switching tags:
https://github.com/lolilolicon/dwm/blob … _stay.diff
Last edited by lolilolicon (2010-11-04 19:21:22)
This silver ladybug at line 28...
Offline
Feedback appreciated!
More a question rather than feedback about the patch. I love the idea (so much so that I have my own based on your original post), but what is the advantage of patching dwm.c over just using config.h to generate the the scratch pad?
I just use:
static const Rule rules[] = {
{ NULL, NULL, "pad", 0, True, -1 }, };
static const char *padcmd[] = { "urxvtc", "-title", "pad", "-geometry", "64x10+540+24", NULL };
static Key keys[] = {
{ ControlMask|Mod1Mask, XK_p, spawn, {.v = padcmd } }, }
Offline
@jasonwryan
I'm happy you liked the idea
Do you always ^D after you've used the pad? Because with your config.h , it seems you cannot toggle display of the scratchpad.
The advantages this new patch has over the original config.h approach are:
*) First launch (i.e. the pad hasn't been created yet):
In the old days, I have to press Mod+Ctrl+x (padcmd) to create the pad, then press Mod+x (toggleview pad's tag) to bring it up.
Now, I can just press Mod+X to bring it up. The pad will be created if no pad has been created yet.
*) Auto focus:
In the old days, I have to press Mod+j or move the mouse to get focus on the pad, which is annoying...
Now, the pad will always get the focus immediately after it's brought up.
*) The tag/tagbar:
In the old days, I put the pad in its own tag "~" (the last in tags[]). This tag will be shown on the tagbar if not additionally patching dwm.c (in an ugly manner). And, when I use Mod+n to cycle (cycle.c) through all tags, this "~" tag is also shown, which I dislike.
Now, the pad's tag is invisible to the user, resolving all those issues.
*) Positioning
In the old days, the position of the pad is controlled by the "+x+y" part of -geometry.
The pad's x, y coordinates are defined in dwm.c, ignoring the +x+y part of -geometry. This brings finer control over the positioning of the pad, e.g. my patch puts it in the center of the screen.
Simply put, it's now a fairly usable (like, real) scratchpad. I think.
Last edited by lolilolicon (2010-11-04 18:08:39)
This silver ladybug at line 28...
Offline
Yes - I am toggleless
On the plus side, everything else works pretty much as I need it. But I'll give your patch a spin later today on both my machines just to see how it runs.
Nice new avatar, btw.
Offline
Yes - I am toggleless
On the plus side, everything else works pretty much as I need it. But I'll give your patch a spin later today on both my machines just to see how it runs.
Nice new avatar, btw.
I read "I am topless"
Thanks for the interest.
(learning a bit inkscape (-:)
This silver ladybug at line 28...
Offline
Tested on vanilla 5.8.2 - first patch applies cleanly, but (probably due to a misunderstanding on my part) doesn't exhibit the expected behaviours. No toggle effect (subsequent presses open more instances), and the pad opens in layout mode of the client (eg, tiled or monocle).
I used this in config.h:
static const char scratchpadname[] = "scratchy";
static const char *scratchpadcmd[] = { "urxvtc", "-name", "scratchy", "-geometry", "70x12+730+24", NULL };
{ MODKEY, XK_s, togglescratch, {.v = scratchpadcmd } },
Am I missing something?
Offline
Works for me, (just tried with vanilla 5.8.2 with only this patch applied)
config:
--- config.def.h 2010-06-04 18:39:15.000000000 +0800
+++ config.h 2010-11-05 10:55:12.220006659 +0800
@@ -47,9 +47,12 @@
/* commands */
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "uxterm", NULL };
+static const char scratchpadname[] = "scratchy";
+static const char *scratchpadcmd[] = { "urxvtc", "-name", scratchpadname, "-geometry", "80x20", NULL };
static Key keys[] = {
/* modifier key function argument */
+ { MODKEY, XK_x, togglescratch, {.v = scratchpadcmd} },
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
Are you sure you're pressing the correct key combo?
Last edited by lolilolicon (2010-11-05 03:04:43)
This silver ladybug at line 28...
Offline