On Mon, Nov 9, 2009 at 4:44 PM, Adrian C. <[email protected]> wrote:

> On Sun, 8 Nov 2009, bob wrote:
>>
>>  +-- { rule = { class = "dosbox" },
>>> +--   callback = awful.placement.centered }
>>>
>>
>> This will not work, there is no property.
>>
>> W: awesome: luaA_dofunction:108: error while running function
>> stack traceback:
>>        [C]: in function 'pairs'
>>        /usr/share/awesome/lib/awful/rules.lua:97: in function
>> </usr/share/awesome/lib/awful/rules.lua:92>
>> error: /usr/share/awesome/lib/awful/rules.lua:97: bad argument #1 to
>> 'pairs' (table expected, got nil)
>>
>
Good point, patch attached which fixes this. It will be checked if there are
properties in the entry to iterate now.


>  +--   callback = awful.placement.centered }
>>
>
> This will not work if placement.no_overlap is used in the manage signal
> handler. Maybe there should be a better example.
>

Yeah the default config sets no_overlap on some clients, new example
attached as a patch, I hope this one is better.

Both patches assume latest master from git.

Somewhat unrelated: I'm "bob" I unsubscribed my gmail account, my new (real)
name and e-mail can also be used in the commit so I'm easier to track /
blame.
From 0d53dd1f293407fc49ad80b60d6a741a73cd5fa3 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <[email protected]>
Date: Mon, 9 Nov 2009 18:15:06 +0100
Subject: [PATCH 1/2] Rules: check if properties of a rule exist

Actually check if properties are set now, since we can also only
apply callbacks now.
---
 lib/awful/rules.lua.in |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in
index ccee9c8..8859b2a 100644
--- a/lib/awful/rules.lua.in
+++ b/lib/awful/rules.lua.in
@@ -94,8 +94,10 @@ function apply(c)
     local callbacks = {}
     for _, entry in ipairs(rules) do
         if match(c, entry.rule) then
-            for property, value in pairs(entry.properties) do
-                props[property] = value
+            if entry.properties then
+                for property, value in pairs(entry.properties) do
+                    props[property] = value
+                end
             end
             if entry.callback then
                 table.insert(callbacks, entry.callback)
-- 
1.6.5.2

From 2160d74fbfdc91be6b3b8fc45301c731be3b4f18 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <[email protected]>
Date: Mon, 9 Nov 2009 19:12:14 +0100
Subject: [PATCH 2/2] Rules: change example

change example since the example with a centered client doesnt work
on the default config (due to no_overlap).
---
 lib/awful/rules.lua.in |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in
index 8859b2a..5ca3c73 100644
--- a/lib/awful/rules.lua.in
+++ b/lib/awful/rules.lua.in
@@ -48,12 +48,15 @@ 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
+-- <p>If you want to apply a custom callback to execute when a rule matched,
+-- for example to pause playing music from mpd when you start dosbox, you
 -- can add:
 -- <br/>
 -- <code>
 -- { rule = { class = "dosbox" },
---   callback = awful.placement.centered }
+--   callback = function(c)
+--      awful.util.spawn('mpc pause')
+--   end }
 -- </code>
 -- </p>
 -- <p>Note that all "rule" entries need to match. If any of the entry does not
-- 
1.6.5.2

Reply via email to