You are not logged in.
Is there a DWM patch to let modkey+space cycle between layouts like in XMonad and Awesome? I saw the thread here that suggests using cycle.c: https://bbs.archlinux.org/viewtopic.php … 18#p761018
However, cycle.c allows cycling across tags rather than layouts. Does anyone else know how to enable this functionality?
Last edited by choogi (2010-08-30 17:20:01)
Offline
I don't think so - but if it is implemented in Awesome, it shouldn't be a big deal to do it in dwm.
If it is something you really want, you should also ask on the suckless ML or in #suckless.
Offline
This is how I did it:
void
nextlayout(const Arg *arg) {
Layout *l;
for (l=(Layout *)layouts;l != selmon->lt[selmon->sellt];l++);
if (l->symbol && (l + 1)->symbol)
setlayout(&((Arg) { .v = (l + 1) }));
else
setlayout(&((Arg) { .v = layouts }));
}
void
prevlayout(const Arg *arg) {
Layout *l;
for (l=(Layout *)layouts;l != selmon->lt[selmon->sellt];l++);
if (l != layouts && (l - 1)->symbol)
setlayout(&((Arg) { .v = (l - 1) }));
else
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
}
and you should NULL terminate the layouts by adding:
{ .symbol = NULL, .arrange = NULL },
to your layouts in config.h
Offline
what version are you using? I'm using 5.8.2 and this works out of the box.
Offline
what version are you using? I'm using 5.8.2 and this works out of the box.
I believe the out of box behaviour is to cylce between two of the three default layouts (float and tile).
thayer williams ~ cinderwick.ca
Offline
My default behavior in 5.8.2 toggled between the current layout and the last layout that I used.
bob127's functions works perfectly for me on 5.8.2.
Thanks all!
Offline
sorry to bump this thread, but i too want the same behaviour as choogi, but can't seem to get bob127's suggestion to work.
do i need to add this to dwm.c ?
void
nextlayout(const Arg *arg) {
Layout *l;
for (l=(Layout *)layouts;l != selmon->lt[selmon->sellt];l++);
if (l->symbol && (l + 1)->symbol)
setlayout(&((Arg) { .v = (l + 1) }));
else
setlayout(&((Arg) { .v = layouts }));
}
void
prevlayout(const Arg *arg) {
Layout *l;
for (l=(Layout *)layouts;l != selmon->lt[selmon->sellt];l++);
if (l != layouts && (l - 1)->symbol)
setlayout(&((Arg) { .v = (l - 1) }));
else
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
}
and i didn't understand about this, either:
{ .symbol = NULL, .arrange = NULL },
sorry, i am new to c.
EDIT: so i just looked at bob127's configs at his website, and added the code accordingly to my configs, and now cyclelayouts works great.
Thanks bob, for the patch.
Last edited by x33a (2011-01-14 10:59:49)
Offline
Im also interested about cycle layouts. Wouldnt it be better approach to modify setlayout() to cycle through layouts? Ill see if i can do it. Any tips are welcome.
Offline
This thread is nearly 3 years old, with 2 years since the penultimate post. Normally this would be closed as a zombie but the thread is short and to the point. Adding a possibly better solution here makes sense.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I had a couple line function to do this when I used dwm. I thought I posted it on these forums somewhere, but I can't find it now. I scoured the dwm hackers thread, so it must have been somewhere else.
But here's the main idea recreated from memory and *not* tested.
int cycle_layout(const Arg *arg) {
static unsigned short int layout = 0;
if (layout++ > sizeof(layouts)/sizeof(layouts[0])) layout = 0;
setlayout( &((Arg) {.v = &layouts[layout]}));
}
...
{ MODKEY, XK_Space, cylce_layout, {0} },
You could also replace layout++ with layout+=arg->i then pass a +1 or -1 .i parameter to cycle forward or back. But that would require a second conditional in the function to check "if (layout < 0) layout = sizeof(layouts)/sizeof(layouts[0])".
Last edited by Trilby (2013-08-02 17:32:27)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline