Update
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
-- WirePlumber
|
||||
--
|
||||
-- Copyright © 2022 Collabora Ltd.
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
--
|
||||
-- example of a user injectible hook to link a node to a custom target
|
||||
|
||||
lutils = require ("linking-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "linking/sample-find-user-target",
|
||||
before = "linking/find-defined-target",
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "select-target" },
|
||||
},
|
||||
},
|
||||
execute = function (event)
|
||||
local source, om, si, si_props, si_flags, target =
|
||||
lutils:unwrap_select_target_event (event)
|
||||
|
||||
-- bypass the hook if the target is already picked up
|
||||
if target then
|
||||
return
|
||||
end
|
||||
|
||||
log:info (si, "in find-user-target")
|
||||
|
||||
-- implement logic here to find a suitable target
|
||||
|
||||
-- store the found target on the event,
|
||||
-- the next hooks will take care of linking
|
||||
event:set_data ("target", target)
|
||||
end
|
||||
}:register ()
|
||||
Reference in New Issue
Block a user