Files
dotfiles/wireplumber/scripts/linking/find-user-target.lua.example
Antoine Phan 0cd53e0b65 Moving files:
2024-07-27 00:06:16 +07:00

38 lines
925 B
Plaintext

-- 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 ()