On Sun, Nov 8, 2009 at 2:05 PM, Julien Danjou <[email protected]> wrote:
> At 1257683134 time_t, bob wrote:
> > Added documentation, applies to master branch.
> > +-- <code>
> > +-- { rule = { class = "dosbox" },
> > +-- callback = function(c)
> > +-- awful.placement.centered(c, nil)
> > +-- end }
>
> callback = awful.placement.centered
> is enough actually.
>
> > + -- Apply callback on client when rule matched.
> > + if entry.callback then
> > + entry.callback(c)
> > + end
> > end
>
> I really doubt it'll work.
>
I've tested this and it works for me(tm). Or do you doubt it's usefulness ?
I personally only use this to center certain applications, so I thought
about adding a "centered" property with similar logic as "floating". But
people might aswell want to do something entirely else, so a callback is
more flexible.
diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in
index 55bcc08..cdd79cc 100644
--- a/lib/awful/rules.lua.in
+++ b/lib/awful/rules.lua.in
@@ -47,6 +47,14 @@ module("awful.rules")
-- properties = { tag = mytagobject, switchtotag = true } }
-- </code>
-- </p>
+-- <p>If you want to apply a custom callback to execute when a rule matched, you
+-- can add:
+-- <br/>
+-- <code>
+-- { rule = { class = "dosbox" },
+-- callback = awful.placement.centered }
+-- </code>
+-- </p>
-- <p>Note that all "rule" entries need to match. If any of the entry does not
-- match, the rule won't be applied.</p>
-- <p>If a client matches multiple rules, their applied in the order they are
@@ -113,6 +121,10 @@ function apply(c)
if props.focus then
client.focus = c
end
+ -- Apply callback on client when rule matched.
+ if entry.callback then
+ entry.callback(c)
+ end
end
client.add_signal("manage", apply)