Implement callback arg called on client raise
Existing arg is renamed to spawn_callback.
This commit is contained in:
parent
5c2338fad8
commit
9673deca61
23
init.lua
23
init.lua
|
@ -31,8 +31,8 @@ awful.rules.add_rule_source("launch",
|
|||
|
||||
gears.table.crush(props, data.props)
|
||||
|
||||
if data.callback then
|
||||
table.insert(callbacks, data.callback)
|
||||
if data.spawn_callback then
|
||||
table.insert(callbacks, data.spawn_callback)
|
||||
end
|
||||
|
||||
shared.pending[id] = nil
|
||||
|
@ -87,7 +87,7 @@ end
|
|||
-- @param args.props Properties to apply to the client.
|
||||
-- @param args.pwd Pathname to the working directory for new clients.
|
||||
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
|
||||
-- @param args.callback Function to call with client when it spawns.
|
||||
-- @param args.spawn_callback Function to call with client when it spawns.
|
||||
-- @param args.factory The factory to use (see wm-launch's -f flag).
|
||||
-- @param args.firejail If true, run cmd with firejail.
|
||||
-- @return The client's ID.
|
||||
|
@ -98,7 +98,7 @@ local function spawn(cmd, args)
|
|||
local data = {
|
||||
props = args.props or {},
|
||||
pwd = args.pwd,
|
||||
callback = args.callback,
|
||||
spawn_callback = args.spawn_callback,
|
||||
timeout = math.ceil(args.timeout or 10),
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ setmetatable(launch.spawn, {__call = function (_, ...) spawn(...) end})
|
|||
-- @param args.props Properties to apply to the client.
|
||||
-- @param args.pwd Pathname to the working directory for new clients.
|
||||
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
|
||||
-- @param args.callback Function to call with client when it spawns.
|
||||
-- @param args.spawn_callback Function to call with client when it spawns.
|
||||
-- @param args.factory The factory to use (see wm-launch's -f flag).
|
||||
-- @param args.firejail If true, run cmd with firejail.
|
||||
-- @param args.filter Function to filter clients that are considered.
|
||||
|
@ -189,7 +189,8 @@ end
|
|||
-- @param args.props Properties to apply to the client.
|
||||
-- @param args.pwd Pathname to the working directory for new clients.
|
||||
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
|
||||
-- @param args.callback Function to call with client when it spawns.
|
||||
-- @param args.spawn_callback Function to call with client when it spawns.
|
||||
-- @param args.callback Function to call with client when it spawns or is raised.
|
||||
-- @param args.factory The factory to use (see wm-launch's -f flag).
|
||||
-- @param args.firejail If true, run cmd with firejail.
|
||||
-- @param args.filter Function to filter clients that are considered.
|
||||
|
@ -205,8 +206,18 @@ function launch.spawn.raise_or_spawn(cmd, args)
|
|||
if c then
|
||||
c:emit_signal("request::activate", "launch.spawn.raise_or_spawn",
|
||||
{raise=true})
|
||||
if args.callback then
|
||||
args.callback(c)
|
||||
end
|
||||
return args.id
|
||||
end
|
||||
if args.callback then
|
||||
local cb = args.spawn_callback
|
||||
args.spawn_callback = function (c)
|
||||
if cb then cb(c) end
|
||||
args.callback(c)
|
||||
end
|
||||
end
|
||||
return spawn(cmd, args)
|
||||
end
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ local panel = {}
|
|||
-- TODO: Reapply args on restart with rule source.
|
||||
-- See: https://github.com/awesomeWM/awesome/issues/2725
|
||||
local function spawn(cmd, args)
|
||||
local cb = args.callback
|
||||
args.callback = function (c)
|
||||
local cb = args.spawn_callback
|
||||
args.spawn_callback = function (c)
|
||||
c.hidden = true
|
||||
c.sticky = true
|
||||
c.floating = true
|
||||
|
@ -47,7 +47,7 @@ end
|
|||
-- @param args.props Properties to apply to the client.
|
||||
-- @param args.pwd Pathname to the working directory for new clients.
|
||||
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
|
||||
-- @param args.callback Function to call with client when it spawns.
|
||||
-- @param args.spawn_callback Function to call with client when it spawns.
|
||||
-- @param args.factory The factory to use (see wm-launch's -f flag).
|
||||
-- @param args.firejail If true, run cmd with firejail.
|
||||
-- @param args.filter Function to filter clients that are considered.
|
||||
|
@ -58,7 +58,7 @@ function panel.toggle(cmd, args)
|
|||
if c then
|
||||
toggle(c)
|
||||
else
|
||||
local a = {callback = function (c) toggle(c) end}
|
||||
local a = {spawn_callback = function (c) toggle(c) end}
|
||||
gtable.crush(a, args)
|
||||
spawn(cmd, a)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue