mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 05:08:04 +02:00
scripts/policy-desktop: add move & follow settings handlers
This commit is contained in:
parent
67ab0eced2
commit
6bc782d070
1 changed files with 68 additions and 0 deletions
68
src/scripts/policy-desktop/move-follow.lua
Normal file
68
src/scripts/policy-desktop/move-follow.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
-- WirePlumber
|
||||
--
|
||||
-- Copyright © 2022 Collabora Ltd.
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
--
|
||||
-- Move & follow settings handlers. If the relevant settings are enabled,
|
||||
-- install hooks that will schedule a rescan of the graph when needed
|
||||
|
||||
local config = require ("policy-config")
|
||||
local handles = {}
|
||||
|
||||
function handleFollowSetting (enable)
|
||||
if (not handles.follow_hook) and (enable == true) then
|
||||
handles.follow_hook = SimpleEventHook {
|
||||
name = "follow@policy-desktop",
|
||||
type = "on-event",
|
||||
priority = HookPriority.NORMAL,
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "metadata-changed" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "c", "default.audio.source",
|
||||
"default.audio.sink", "default.video.source" },
|
||||
},
|
||||
},
|
||||
execute = function (event)
|
||||
local source = event:get_source ()
|
||||
source:call ("schedule-rescan")
|
||||
end
|
||||
}
|
||||
handles.follow_hook:register ()
|
||||
elseif (handles.follow_hook) and (enable == false) then
|
||||
handles.follow_hook:remove ()
|
||||
handles.follow_hook = nil
|
||||
end
|
||||
end
|
||||
|
||||
function handleMoveSetting (enable)
|
||||
if (not handles.move_hook) and (enable == true) then
|
||||
handles.move_hook = SimpleEventHook {
|
||||
name = "move@policy-desktop",
|
||||
type = "on-event",
|
||||
priority = HookPriority.NORMAL,
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "metadata-changed" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "c", "target.node", "target.object" },
|
||||
},
|
||||
},
|
||||
execute = function (event)
|
||||
local source = event:get_source ()
|
||||
source:call ("schedule-rescan")
|
||||
end
|
||||
}
|
||||
handles.move_hook:register()
|
||||
elseif (handles.move_hook) and (enable == false) then
|
||||
handles.move_hook:remove ()
|
||||
handles.move_hook = nil
|
||||
end
|
||||
end
|
||||
|
||||
config:subscribe ("follow", handleFollowSetting)
|
||||
handleFollowSetting (config.follow)
|
||||
|
||||
config:subscribe ("move", handleMoveSetting)
|
||||
handleMoveSetting (config.move)
|
||||
Loading…
Add table
Reference in a new issue