Merge pull request #2716 from psychon/once_optional_rules

awful.spawn: Make rules optional in once / single_instance
This commit is contained in:
mergify[bot] 2019-03-03 21:20:10 +00:00 committed by GitHub
commit 3ff795b4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -388,7 +388,9 @@ local function apply_singleton_rules(c, props, callbacks)
if info then
c.single_instance_id = info.hash
gtable.crush(props, info.rules)
if info.rules then
gtable.crush(props, info.rules)
end
table.insert(callbacks, info.callback)
table.insert(info.instances, c)

View File

@ -637,7 +637,7 @@ end
-- Note that this also wont work with shell or terminal commands.
--
-- @tparam string|table cmd The command.
-- @tparam table rules The properties that need to be applied to the client.
-- @tparam[opt] table rules The properties that need to be applied to the client.
-- @tparam[opt] function matcher A matching function to find the instance
-- among running clients.
-- @tparam[opt] string unique_id A string to identify the client so it isn't executed
@ -669,7 +669,7 @@ end
-- faster than the client has time to start.
--
-- @tparam string|table cmd The command.
-- @tparam table rules The properties that need to be applied to the client.
-- @tparam[opt] table rules The properties that need to be applied to the client.
-- @tparam[opt] function matcher A matching function to find the instance
-- among running clients.
-- @tparam[opt] string unique_id A string to identify the client so it isn't executed

View File

@ -334,6 +334,20 @@ local steps = {
function()
if #client.get() ~= 1 then return end
assert(matcher_called)
client.get()[1]:kill()
return true
end,
-- Test that rules are optional
function()
if #client.get() ~= 0 then return end
spawn.single_instance(tiny_client("client4"))
spawn.once(tiny_client("client5"))
return true
end,
function()
if #client.get() ~= 2 then return end
return true
end,
}