Added documentation, applies to master branch.

On Sun, Nov 8, 2009 at 10:28 AM, Julien Danjou <[email protected]> wrote:

> At 1257618782 time_t, bob wrote:
> > The patch is added as an attachment. (It will apply to lib/awful/
> > rules.lua.in against git f3509f745a8e15d252d4d0ed81dfadc07009d425).
>
> Documentation update is missing.
>
> Cheers,
> --
> Julien Danjou
> // ᐰ <[email protected]>   http://julien.danjou.info
> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
> // Life is life. Lalalalala.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEUEARECAAYFAkr2jz4ACgkQpGK1HsL权˜늽㙟鹇ᑦ㬾文W
> tACcCoeplOkPxxWTqifD/7o7aTiwUpE=
> =aZyG
> -----END PGP SIGNATURE-----
>
>
From 948bcaa17220976dfdceee414580511d7f21f756 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <[email protected]>
Date: Sun, 8 Nov 2009 13:20:44 +0100
Subject: [PATCH] Rules.lua: Add callback option

Add callback option to execute when a rule matched.

Signed-off-by: Hiltjo Posthuma <[email protected]>
---
 lib/awful/rules.lua.in |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in
index 55bcc08..d776b89 100644
--- a/lib/awful/rules.lua.in
+++ b/lib/awful/rules.lua.in
@@ -47,6 +47,16 @@ 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 = function(c)
+--       awful.placement.centered(c, nil)
+--   end }
+-- </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 +123,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)
-- 
1.6.5.2

Reply via email to