[dwm] Flexible rules

From: Carlos Pita <carlosjosepita_AT_gmail.com>
Date: Thu, 19 Feb 2009 19:20:21 -0200

Hi all,

I think it could be useful to incorporate the following to dwm, in
order to achieve more customized rule conditions and actions in the
cases it's needed without compromising the rest.

typedef void (RuleAction)(Client *c, XClassHint* ch);

typedef struct {
    .....
    RuleAction *action;
} Rule;

void
applyrules(Client *c) {
.....
        for(i = 0; i < LENGTH(rules); i++) {
....
                if (r->action) r->action(c, &ch);
....
}

One motivation for this change is that I like neither having all
firefox windows floating nor all of them tiled: for javascript popups
and browser dialogs I prefer floats, while for main navigator windows
I prefer to have them maximised in monocle layout or tiled. There is
no way to tell javascript popups and main navigator windows apart:
they share the same class and name, and the title is related to the
browser contents (and it's initialized after manage() is called
anyway, from the <title> tag). The only more or less reliable way to
identify popups windows I can figure out is to check that their
initial requested size is considerably smaller than my screen size;
this works pretty well, in fact. So, using the above, my config.h
would look like:

void
firefoxPopupRule(Client *c, XClassHint *ch) {
    XWindowAttributes wa;
    XGetWindowAttributes(dpy, c->win, &wa);
    if (wa.height > 1000 && wa.width > 1000) {
        c->isfloating = False;
    }
}

static Rule rules[] = {
   /* class instance title tags mask
isfloating extraaction */
    ....
    { "Gran Paradiso", NULL, NULL, 0,
True, NULL },
    { "Gran Paradiso", "Navigator",NULL, 0,
True, firefoxPopupRule },
};

I'll be glad to hear what you have to say regarding this.

Regards
-Carlos
Received on Thu Feb 19 2009 - 21:20:21 UTC

This archive was generated by hypermail 2.2.0 : Thu Feb 19 2009 - 21:36:04 UTC