Implement launch.spawn.here

This commit is contained in:
James Reed 2019-09-14 19:46:21 -06:00
parent 9673deca61
commit a5e53318ee
No known key found for this signature in database
GPG Key ID: 8F79994F6B8378C1
1 changed files with 42 additions and 0 deletions

View File

@ -221,4 +221,46 @@ function launch.spawn.raise_or_spawn(cmd, args)
return spawn(cmd, args)
end
--- Spawn clients on a tag.
--
-- Usage: `launch.spawn.here().spawn("xterm")`
--
-- @param tag_func Optional function that returns the tag, defaults to
-- `awful.screen.focused().selected_tag`.
-- @return A table with the functions: spawn, single_instance, raise_or_spawn.
-- @function spawn.here
function launch.spawn.here(tag_func)
local here = {}
local function with_tag(func, cmd, args)
local tag
if tag_func then
tag = tag_func()
else
tag = awful.screen.focused().selected_tag
end
local a = {
filter = function (c) return c:isvisible() end,
props = {tag = tag},
}
gears.table.crush(a, args or {})
func(cmd, a)
end
function here.spawn(...)
with_tag(launch.spawn, ...)
end
function here.single_instance(...)
with_tag(launch.spawn.single_instance, ...)
end
function here.raise_or_spawn(...)
with_tag(launch.spawn.raise_or_spawn, ...)
end
return here
end
return launch