Implement launch.spawn.here
This commit is contained in:
parent
9673deca61
commit
a5e53318ee
42
init.lua
42
init.lua
|
@ -221,4 +221,46 @@ function launch.spawn.raise_or_spawn(cmd, args)
|
||||||
return spawn(cmd, args)
|
return spawn(cmd, args)
|
||||||
end
|
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
|
return launch
|
||||||
|
|
Loading…
Reference in New Issue