lt will point to a foo-layout during cleanup now (Gottox' suggestion), and togglelayout respects Arg->v
--- a/dwm.c Wed Jun 11 09:34:00 2008 +0100
+++ b/dwm.c Wed Jun 11 10:25:02 2008 +0100
@@ -363,8 +363,11 @@
void
cleanup(void) {
Arg a = {.i = ~0};
+ Layout foo = { 0 };
+
close(STDIN_FILENO);
view(&a);
+ lt = &foo;
while(stack)
unmanage(stack);
if(dc.font.set)
@@ -1476,7 +1479,9 @@
void
togglelayout(const Arg *arg) {
- if(++lt == &layouts[LENGTH(layouts)])
+ if(arg->v)
+ lt = (Layout *)arg->v;
+ else if(++lt == &layouts[LENGTH(layouts)])
lt = &layouts[0];
if(sel)
arrange();