diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in index 5e942660f..9c41f943c 100644 --- a/lib/awful/rules.lua.in +++ b/lib/awful/rules.lua.in @@ -71,6 +71,30 @@ module("awful.rules") -- --

-- +--

To match multiple clients with an exception one can couple 'except' or +-- 'except_any' with the rules: +--
+-- +-- { rule = { class = "Firefox" }, +-- except = { instance = "Navigator" }, +-- properties = {floating = true}, +-- }, +-- +--
+-- +-- { rule_any = { class = { "Pidgin", "Xchat" } }, +-- except_any = { role = { "conversation" } }, +-- properties = { tag = tags[1][1] } +-- } +--
+-- +-- { rule = {}, +-- except_any = { class = { "Firefox", "Vim" } }, +-- properties = { floating = true } +-- } +-- +--

+-- -- @class table -- @name rules rules = {} @@ -80,6 +104,7 @@ rules = {} -- @param rule The rule to check. -- @return True if it matches, false otherwise. function match(c, rule) + if not rule then return false end for field, value in pairs(rule) do if c[field] then if type(c[field]) == "string" then @@ -101,6 +126,7 @@ end -- @param rules The rule to check. -- @return True if at least one rule is matched, false otherwise. function match_any(c, rule) + if not rule then return false end for field, values in pairs(rule) do if c[field] then for _, value in ipairs(values) do @@ -121,8 +147,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 (match(c, entry.rule) or match_any(c, entry.rule_any)) and + (not match(c, entry.except) and not match_any(c, entry.except_any)) then if entry.properties then for property, value in pairs(entry.properties) do props[property] = value