rules: allow defining exceptions to a rule - except, and except_any
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" }, except = { instance = "Navigator" }, properties = {floating = true}, } More examples in the docs. Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
44b8549770
commit
55f5ba6911
|
@ -71,6 +71,30 @@ module("awful.rules")
|
||||||
-- </code>
|
-- </code>
|
||||||
-- </p>
|
-- </p>
|
||||||
--
|
--
|
||||||
|
-- <p> To match multiple clients with an exception one can couple 'except' or
|
||||||
|
-- 'except_any' with the rules:
|
||||||
|
-- <br/>
|
||||||
|
-- <code>
|
||||||
|
-- { rule = { class = "Firefox" },
|
||||||
|
-- except = { instance = "Navigator" },
|
||||||
|
-- properties = {floating = true},
|
||||||
|
-- },
|
||||||
|
-- </code>
|
||||||
|
-- <br/>
|
||||||
|
-- <code>
|
||||||
|
-- { rule_any = { class = { "Pidgin", "Xchat" } },
|
||||||
|
-- except_any = { role = { "conversation" } },
|
||||||
|
-- properties = { tag = tags[1][1] }
|
||||||
|
-- }
|
||||||
|
-- <br/>
|
||||||
|
-- <code>
|
||||||
|
-- { rule = {},
|
||||||
|
-- except_any = { class = { "Firefox", "Vim" } },
|
||||||
|
-- properties = { floating = true }
|
||||||
|
-- }
|
||||||
|
-- </code>
|
||||||
|
-- </p>
|
||||||
|
--
|
||||||
-- @class table
|
-- @class table
|
||||||
-- @name rules
|
-- @name rules
|
||||||
rules = {}
|
rules = {}
|
||||||
|
@ -80,6 +104,7 @@ rules = {}
|
||||||
-- @param rule The rule to check.
|
-- @param rule The rule to check.
|
||||||
-- @return True if it matches, false otherwise.
|
-- @return True if it matches, false otherwise.
|
||||||
function match(c, rule)
|
function match(c, rule)
|
||||||
|
if not rule then return false end
|
||||||
for field, value in pairs(rule) do
|
for field, value in pairs(rule) do
|
||||||
if c[field] then
|
if c[field] then
|
||||||
if type(c[field]) == "string" then
|
if type(c[field]) == "string" then
|
||||||
|
@ -101,6 +126,7 @@ end
|
||||||
-- @param rules The rule to check.
|
-- @param rules The rule to check.
|
||||||
-- @return True if at least one rule is matched, false otherwise.
|
-- @return True if at least one rule is matched, false otherwise.
|
||||||
function match_any(c, rule)
|
function match_any(c, rule)
|
||||||
|
if not rule then return false end
|
||||||
for field, values in pairs(rule) do
|
for field, values in pairs(rule) do
|
||||||
if c[field] then
|
if c[field] then
|
||||||
for _, value in ipairs(values) do
|
for _, value in ipairs(values) do
|
||||||
|
@ -121,8 +147,8 @@ function apply(c)
|
||||||
local props = {}
|
local props = {}
|
||||||
local callbacks = {}
|
local callbacks = {}
|
||||||
for _, entry in ipairs(rules) do
|
for _, entry in ipairs(rules) do
|
||||||
if (entry.rule and match(c, entry.rule)) or
|
if (match(c, entry.rule) or match_any(c, entry.rule_any)) and
|
||||||
(entry.rule_any and match_any(c, entry.rule_any)) then
|
(not match(c, entry.except) and not match_any(c, entry.except_any)) then
|
||||||
if entry.properties then
|
if entry.properties then
|
||||||
for property, value in pairs(entry.properties) do
|
for property, value in pairs(entry.properties) do
|
||||||
props[property] = value
|
props[property] = value
|
||||||
|
|
Loading…
Reference in New Issue