Remove all usage of the now deprecated `awful.rules`.

This commit is contained in:
Emmanuel Lepage Vallee 2019-10-06 21:53:08 -04:00
parent e309059f4c
commit 20743a9a16
13 changed files with 73 additions and 63 deletions

View File

@ -1296,7 +1296,7 @@ end
-- @staticfct awful.client.iterate -- @staticfct awful.client.iterate
-- @usage -- un-minimize all urxvt instances -- @usage -- un-minimize all urxvt instances
-- local urxvt = function (c) -- local urxvt = function (c)
-- return awful.rules.match(c, {class = "URxvt"}) -- return ruled.client.match(c, {class = "URxvt"})
-- end -- end
-- --
-- for c in awful.client.iterate(urxvt) do -- for c in awful.client.iterate(urxvt) do
@ -1326,7 +1326,7 @@ end
-- @usage -- run or raise urxvt (perhaps, with tabs) on modkey + semicolon -- @usage -- run or raise urxvt (perhaps, with tabs) on modkey + semicolon
-- awful.key({ modkey, }, 'semicolon', function () -- awful.key({ modkey, }, 'semicolon', function ()
-- local matcher = function (c) -- local matcher = function (c)
-- return awful.rules.match(c, {class = 'URxvt'}) -- return ruled.client.match(c, {class = 'URxvt'})
-- end -- end
-- awful.client.run_or_raise('urxvt', matcher) -- awful.client.run_or_raise('urxvt', matcher)
-- end); -- end);

View File

@ -185,7 +185,7 @@
-- --
-- This should (if the program correctly implements the protocol) result in -- This should (if the program correctly implements the protocol) result in
-- `c.startup_id` to at least match `something`. -- `c.startup_id` to at least match `something`.
-- This identifier can then be used in `awful.rules` to configure the client. -- This identifier can then be used in `ruled.client` to configure the client.
-- --
-- Awesome can automatically set the `DESKTOP_STARTUP_ID` variable. This is used -- Awesome can automatically set the `DESKTOP_STARTUP_ID` variable. This is used
-- by `awful.spawn` to specify additional rules for the startup. For example: -- by `awful.spawn` to specify additional rules for the startup. For example:
@ -206,7 +206,7 @@
-- })' -- })'
-- --
-- This table contains the client properties that are valid when used the -- This table contains the client properties that are valid when used the
-- `sn_rules` or `prop` function argument. They are the same as in `awful.rules`. -- `sn_rules` or `prop` function argument. They are the same as in `ruled.client`.
-- --
--@DOC_rules_index_COMMON@ --@DOC_rules_index_COMMON@
-- --
@ -334,7 +334,7 @@ end
-- Applying properties or running a callback requires the program/client to -- Applying properties or running a callback requires the program/client to
-- support startup notifications. -- support startup notifications.
-- --
-- See `awful.rules.execute` for more details about the format of `sn_rules`. -- See `ruled.client.execute` for more details about the format of `sn_rules`.
-- --
-- @tparam string|table cmd The command. -- @tparam string|table cmd The command.
-- @tparam[opt=true] table|boolean sn_rules A table of properties to be applied -- @tparam[opt=true] table|boolean sn_rules A table of properties to be applied
@ -636,7 +636,7 @@ end
-- command and rules, you need to specify an UID or only the first one will be -- command and rules, you need to specify an UID or only the first one will be
-- executed. -- executed.
-- --
-- The `rules` are standard `awful.rules`. -- The `rules` are standard `ruled.client`.
-- --
-- This function depends on the startup notification protocol to be correctly -- This function depends on the startup notification protocol to be correctly
-- implemented by the command. See `client.startup_id` for more information. -- implemented by the command. See `client.startup_id` for more information.
@ -649,7 +649,7 @@ end
-- @tparam[opt] string unique_id A string to identify the client so it isn't executed -- @tparam[opt] string unique_id A string to identify the client so it isn't executed
-- multiple time. -- multiple time.
-- @tparam[opt] function callback A callback function when the client is created. -- @tparam[opt] function callback A callback function when the client is created.
-- @see awful.rules -- @see ruled.client
-- @staticfct awful.spawn.once -- @staticfct awful.spawn.once
function spawn.once(cmd, rules, matcher, unique_id, callback) function spawn.once(cmd, rules, matcher, unique_id, callback)
local hash = unique_id or hash_command(cmd, rules) local hash = unique_id or hash_command(cmd, rules)
@ -666,7 +666,7 @@ end
-- This is like `awful.spawn.once`, but will spawn new instances if the previous -- This is like `awful.spawn.once`, but will spawn new instances if the previous
-- has finished. -- has finished.
-- --
-- The `rules` are standard `awful.rules`. -- The `rules` are standard `ruled.client`.
-- --
-- This function depends on the startup notification protocol to be correctly -- This function depends on the startup notification protocol to be correctly
-- implemented by the command. See `client.startup_id` for more information. -- implemented by the command. See `client.startup_id` for more information.
@ -682,7 +682,7 @@ end
-- @tparam[opt] string unique_id A string to identify the client so it isn't executed -- @tparam[opt] string unique_id A string to identify the client so it isn't executed
-- multiple time. -- multiple time.
-- @tparam[opt] function callback A callback function when the client is created. -- @tparam[opt] function callback A callback function when the client is created.
-- @see awful.rules -- @see ruled.client
-- @staticfct awful.spawn.single_instance -- @staticfct awful.spawn.single_instance
function spawn.single_instance(cmd, rules, matcher, unique_id, callback) function spawn.single_instance(cmd, rules, matcher, unique_id, callback)
local hash = unique_id or hash_command(cmd, rules) local hash = unique_id or hash_command(cmd, rules)
@ -709,7 +709,7 @@ local raise_rules = {focus = true, switch_to_tags = true, raise = true}
-- @tparam[opt] string unique_id A string to identify the client so it isn't executed -- @tparam[opt] string unique_id A string to identify the client so it isn't executed
-- multiple time. -- multiple time.
-- @tparam[opt] function callback A callback function when the client is created. -- @tparam[opt] function callback A callback function when the client is created.
-- @see awful.rules -- @see ruled.client
-- @treturn client The client if it already exists. -- @treturn client The client if it already exists.
-- @staticfct awful.spawn.raise_or_spawn -- @staticfct awful.spawn.raise_or_spawn
-- @request client activate spawn.raise_or_spawn granted Activate a client when -- @request client activate spawn.raise_or_spawn granted Activate a client when

View File

@ -1684,8 +1684,8 @@ end
-- Register standard signals. -- Register standard signals.
capi.client.connect_signal("property::screen", function(c) capi.client.connect_signal("property::screen", function(c)
-- First, the delayed timer is necessary to avoid a race condition with -- First, the delayed timer is necessary to avoid a race condition with
-- awful.rules. It is also messing up the tags before the user have a chance -- `ruled.client`. It is also messing up the tags before the user have a
-- to set them manually. -- chance to set them manually.
timer.delayed_call(function() timer.delayed_call(function()
if not c.valid then if not c.valid then
return return

View File

@ -3,7 +3,7 @@
-- Sources -- Sources
-- ======= -- =======
-- --
-- This module holds the business logic used by `awful.rules`. It provides an -- This module holds the business logic used by `ruled.client`. It provides an
-- object on which one can add sets of rules or, alternatively, functions. -- object on which one can add sets of rules or, alternatively, functions.
-- In this module, the sets of rules or custom functions are called sources. -- In this module, the sets of rules or custom functions are called sources.
-- --
@ -29,11 +29,11 @@
-- --
-- @DOC_text_gears_matcher_types_EXAMPLE@ -- @DOC_text_gears_matcher_types_EXAMPLE@
-- --
-- More examples are available in `awful.rules`. -- More examples are available in `ruled.client`.
-- --
-- @author Julien Danjou <julien@danjou.info> -- @author Julien Danjou <julien@danjou.info>
-- @copyright 2009 Julien Danjou -- @copyright 2009 Julien Danjou
-- @see awful.rules -- @see ruled.client
-- @module gears.matcher -- @module gears.matcher
local gtable = require("gears.table") local gtable = require("gears.table")
@ -445,7 +445,7 @@ function matcher:remove_matching_source(name)
return false return false
end end
--- Apply awful.rules.rules to an object. --- Apply ruled.client.rules to an object.
-- --
-- Calling this will apply all properties provided by the matching functions -- Calling this will apply all properties provided by the matching functions
-- and rules. -- and rules.

View File

@ -255,7 +255,7 @@
* (from `awful.client.focus.history.previous`). * (from `awful.client.focus.history.previous`).
* * *menu.clients*: When using the builtin client menu * * *menu.clients*: When using the builtin client menu
* (from `awful.menu.clients`). * (from `awful.menu.clients`).
* * *rules*: When a new client is focused from a rule (from `awful.rules`). * * *rules*: When a new client is focused from a rule (from `ruled.client`).
* * *screen.focus*: When a screen is focused (from `awful.screen.focus`). * * *screen.focus*: When a screen is focused (from `awful.screen.focus`).
* *
* Default implementation: `awful.ewmh.activate`. * Default implementation: `awful.ewmh.activate`.
@ -596,7 +596,7 @@
* multiple of the character size. Honoring size hints will cause the terminal * multiple of the character size. Honoring size hints will cause the terminal
* window to have a small gap at the bottom. * window to have a small gap at the bottom.
* *
* This is enabled by default. To disable it by default, see `awful.rules`. * This is enabled by default. To disable it by default, see `ruled.client`.
* *
* **Signal:** * **Signal:**
* *
@ -946,8 +946,8 @@
* blacklisted_snid[snid] = c * blacklisted_snid[snid] = c
* end * end
* *
* awful.rules.add_rule_source( * ruled.client.add_rule_source(
* "snid", fix_startup_id, {}, {"awful.spawn", "awful.rules"} * "snid", fix_startup_id, {}, {"awful.spawn", "ruled.client"}
* ) * )
* *
* **Signal:** * **Signal:**

View File

@ -1,7 +1,7 @@
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
-- This file provide a simple, yet flexible, test client. -- This file provide a simple, yet flexible, test client.
-- It is used to test the `awful.rules` -- It is used to test the `ruled.client`
local test_client_source = [[ local test_client_source = [[
pcall(require, 'luarocks.loader') pcall(require, 'luarocks.loader')

View File

@ -1,7 +1,5 @@
local timer = require("gears.timer") local timer = require("gears.timer")
local awful = require("awful")
local gtable = require("gears.table") local gtable = require("gears.table")
local gdebug = require("gears.debug")
local runner = { local runner = {
quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1', quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1',
@ -9,21 +7,6 @@ local runner = {
local verbose = os.getenv('VERBOSE') == '1' local verbose = os.getenv('VERBOSE') == '1'
-- Helpers.
--- Add some rules to awful.rules.rules, after the defaults.
local dep = gdebug.deprecate
gdebug.deprecate = function() end
local default_rules = gtable.clone(awful.rules.rules)
gdebug.deprecate = dep
runner.add_to_default_rules = function(r)
gdebug.deprecate = function() end
awful.rules.rules = gtable.clone(default_rules)
table.insert(awful.rules.rules, r)
gdebug.deprecate = dep
end
-- Was the runner started already? -- Was the runner started already?
local running = false local running = false

View File

@ -11,7 +11,7 @@ local c = client.gen_fake {hide_first=true} --DOC_HIDE
place.maximize(c, {honor_padding=true, honor_workarea=true}) --DOC_HIDE place.maximize(c, {honor_padding=true, honor_workarea=true}) --DOC_HIDE
-- Create a titlebar for the client. -- Create a titlebar for the client.
-- By default, `awful.rules` will create one, but all it does is to call this -- By default, `ruled.client` will create one, but all it does is to call this
-- function. -- function.
local top_titlebar = awful.titlebar(c, { local top_titlebar = awful.titlebar(c, {

View File

@ -1,5 +1,7 @@
local awful = require("awful") local awful = require("awful")
local test_client = require("_client") local test_client = require("_client")
local cruled = require("ruled.client")
local gdebug = require("gears.debug")
local has_spawned = false local has_spawned = false
local steps = { local steps = {
@ -177,7 +179,10 @@ end)
local has_error local has_error
-- Disable awful.screen.preferred(c) -- Disable awful.screen.preferred(c)
awful.rules.rules[1].properties.screen = nil local dep = gdebug.deprecate
gdebug.deprecate = function() end
cruled.rules[1].properties.screen = nil
gdebug.deprecate = dep
table.insert(steps, function() table.insert(steps, function()
-- Make sure there is no extra callbacks that causes double screen changes -- Make sure there is no extra callbacks that causes double screen changes

View File

@ -1,6 +1,7 @@
local awful = require("awful") local awful = require("awful")
local test_client = require("_client") local test_client = require("_client")
local runner = require("_runner") local runner = require("_runner")
local cruled = require("ruled.client")
-- This test makes some assumptions about the no_overlap behavior which may not -- This test makes some assumptions about the no_overlap behavior which may not
-- be correct if the screen is in the portrait orientation. -- be correct if the screen is in the portrait orientation.
@ -27,7 +28,8 @@ local rule = {
placement = awful.placement.no_overlap + awful.placement.no_offscreen placement = awful.placement.no_overlap + awful.placement.no_offscreen
} }
} }
table.insert(awful.rules.rules, rule)
cruled.append_rule(rule)
local function check_geometry(c, x, y, width, height) local function check_geometry(c, x, y, width, height)
local g = c:geometry() local g = c:geometry()

View File

@ -1,4 +1,5 @@
local awful = require("awful") local awful = require("awful")
local ruledc = require("ruled.client")
local gears = require("gears") local gears = require("gears")
local test_client = require("_client") local test_client = require("_client")
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1) local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
@ -12,8 +13,8 @@ local tests = {}
-- local border_width = beautiful.border_width -- local border_width = beautiful.border_width
-- Detect "request::manage" race conditions -- Detect "request::manage" race conditions
local real_apply = awful.rules.apply local real_apply = ruledc.apply
function awful.rules.apply(c) function ruledc.apply(c)
assert(#c:tags() == 0) assert(#c:tags() == 0)
return real_apply(c) return real_apply(c)
end end
@ -33,7 +34,7 @@ local function test_rule(rule)
rule.test = nil rule.test = nil
end end
table.insert(awful.rules.rules, rule) ruledc.append_rule(rule)
end end
-- Helper function to search clients -- Helper function to search clients
@ -263,20 +264,20 @@ test_rule {
} }
-- Test the custom sources -- Test the custom sources
assert(awful.rules.add_rule_source("high_priority", function(c, props, _) assert(ruledc.add_rule_source("high_priority", function(c, props, _)
assert(type(c) == "client") assert(type(c) == "client")
assert(props.random2) assert(props.random2)
props.random1 = true props.random1 = true
end, {"awful.spawn"}, {"awful.rules", "low_priority"})) end, {"awful.spawn"}, {"awful.rules", "low_priority"}))
assert(awful.rules.add_rule_source("before2", function() assert(ruledc.add_rule_source("before2", function()
error("This function should not be called") error("This function should not be called")
end, {"awful.spawn"}, {"awful.rules"})) end, {"awful.spawn"}, {"awful.rules"}))
assert(awful.rules.remove_rule_source("before2")) assert(ruledc.remove_rule_source("before2"))
assert(awful.rules.add_rule_source("low_priority", function(c, props, _) assert(ruledc.add_rule_source("low_priority", function(c, props, _)
assert(type(c) == "client") assert(type(c) == "client")
assert(not props.random1) assert(not props.random1)
@ -285,7 +286,7 @@ end, {"awful.spawn", "high_priority"}, {"void", "awful.rules"}))
local temp = gears.debug.print_warning local temp = gears.debug.print_warning
gears.debug.print_warning = function() end gears.debug.print_warning = function() end
assert(not awful.rules.add_rule_source("invalid_source", function() assert(not ruledc.add_rule_source("invalid_source", function()
assert(false, "This cannot happen") assert(false, "This cannot happen")
end, {"awful.rules"}, {"awful.spawn"})) end, {"awful.rules"}, {"awful.spawn"}))
gears.debug.print_warning = temp gears.debug.print_warning = temp

View File

@ -4,21 +4,38 @@ local runner = require( "_runner" )
local awful = require( "awful" ) local awful = require( "awful" )
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
local cruled = require("ruled.client")
local gdebug = require("gears.debug")
local w = nil local w = nil
local w1_draw, w2_draw local w1_draw, w2_draw
-- Replacing the rules is not supported anymore.
local dep = gdebug.deprecate
local function set_rules(new_rules)
gdebug.deprecate = function() end
cruled.rules = {}
cruled.append_rules(new_rules)
gdebug.deprecate = dep
end
-- Disable automatic placement -- Disable automatic placement
awful.rules.rules = { set_rules {
{ rule = { }, properties = { {
border_width = 0, rule = { },
size_hints_honor = false, properties = {
x = 0, border_width = 0,
y = 0, size_hints_honor = false,
width = 100, x = 0,
height = 100, y = 0,
border_color = beautiful.border_color_normal width = 100,
} height = 100,
border_color = beautiful.border_color_normal
}
} }
} }
@ -52,7 +69,7 @@ local steps = {
end end
end, end,
function() function()
awful.rules.rules = { set_rules {
-- All clients will match this rule. -- All clients will match this rule.
{ rule = { },properties = { { rule = { },properties = {
titlebars_enabled = true, titlebars_enabled = true,

View File

@ -2,6 +2,8 @@
local awful = require("awful") local awful = require("awful")
local runner = require("_runner") local runner = require("_runner")
local cruled = require("ruled.client")
-- Some basic assertion that the tag is not marked "urgent" already. -- Some basic assertion that the tag is not marked "urgent" already.
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == nil) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == nil)
@ -31,7 +33,7 @@ local steps = {
-- Select first tag. -- Select first tag.
awful.screen.focused().tags[1]:view_only() awful.screen.focused().tags[1]:view_only()
runner.add_to_default_rules({ rule = { class = "XTerm" }, cruled.append_rule({ rule = { class = "XTerm" },
properties = { tag = "2", focus = true } }) properties = { tag = "2", focus = true } })
awful.spawn("xterm") awful.spawn("xterm")
@ -71,7 +73,7 @@ local steps = {
-- Select first tag. -- Select first tag.
awful.screen.focused().tags[1]:view_only() awful.screen.focused().tags[1]:view_only()
runner.add_to_default_rules({ rule = { class = "XTerm" }, cruled.append_rule({ rule = { class = "XTerm" },
properties = { tag = "2", focus = true, switch_to_tags = true }}) properties = { tag = "2", focus = true, switch_to_tags = true }})
awful.spawn("xterm") awful.spawn("xterm")
@ -93,7 +95,7 @@ local steps = {
client.get()[1]:kill() client.get()[1]:kill()
manage_cb_done = false manage_cb_done = false
runner.add_to_default_rules({rule = { class = "XTerm" }, cruled.append_rule({rule = { class = "XTerm" },
properties = { tag = "2", focus = false }}) properties = { tag = "2", focus = false }})
awful.spawn("xterm") awful.spawn("xterm")