> You still need to provide a list of roles you want/need to match. The
> problem was how to make a negative match.
>
> I have another (better?) example: I want to make all Firefox windows
> floating except ones with instance "Navigator" (all preferences,
> downloads any any window created by some plugin should be floating).

That is a better example. I have been bitten by it myself. Attached is
a small patch (against git head) that adds rule_no key to rules table
to make an exception. 'rule_no' follows the semantics of 'rule' or
'rule_any' depending on the what you have used. Since the patch is
against git head, it might not apply cleanly but you know what to
change :). I will put it on the dev list and see if it can be
included.

-- 
Anurag Priyam
http://about.me/yeban/
From d933ab3130500dbc9ccfa170470a125edc27094a Mon Sep 17 00:00:00 2001
From: Anurag Priyam <[email protected]>
Date: Sun, 27 Mar 2011 19:29:45 +0530
Subject: [PATCH] rules: allow defining exceptions to a rule

So you want to make all Firefox windows floating except the main window
(instance = Navigator). You can either list all possible windows in
rules and make them floating, or make all of them floating except one:

{ rule = { class = "Firefox" },
  rule_no = { instance = "Navigator" },
  properties = {floating = true},
}

Signed-off-by: Anurag Priyam <[email protected]>
---
 lib/awful/rules.lua.in |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in
index 1b1c390..1d8db95 100644
--- a/lib/awful/rules.lua.in
+++ b/lib/awful/rules.lua.in
@@ -74,6 +74,17 @@ module("awful.rules")
 -- </code>
 -- </p>
 --
+-- <p> To match multiple clients with an exception one can couple 'rule_no' with
+-- either 'rule' or 'rule_any', using the same semantics:
+-- <br/>
+-- <code>
+-- { rule = { class = "Firefox" },
+--   rule_no = { instance = "Navigator" },
+--   properties = {floating = true},
+-- },
+-- </code>
+-- </p>
+--
 -- @class table
 -- @name rules
 rules = {}
@@ -124,8 +135,8 @@ function apply(c)
     local props = {}
     local callbacks = {}
     for _, entry in ipairs(rules) do
-        if  (entry.rule and match(c, entry.rule)) or
-            (entry.rule_any and match_any(c, entry.rule_any)) then
+        if  (entry.rule and match(c, entry.rule) and not match(c, entry.rule_no)) or
+            (entry.rule_any and match_any(c, entry.rule_any) and not match_any(c, entry.rule_no)) then
             if entry.properties then
                 for property, value in pairs(entry.properties) do
                     props[property] = value
-- 
1.7.4.1

Reply via email to