--- a/dwm.c 2012-12-03 01:48:48.376556054 +0100 +++ b/dwm.c 2012-12-03 01:47:13.359890123 +0100 @@ -416,8 +416,15 @@ void attach(Client *c) { - c->next = c->mon->clients; - c->mon->clients = c; + if(!c->mon->clients) { + c->next = c->mon->clients; + c->mon->clients = c; + return; + } + Client *at; + for(at = c->mon->clients; at->next; at = at->next); + c->next = at->next; + at->next = c; } void