From f2f889a3e0875ecf0d81ab6ce2420c6c31ed0ee5 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis <george.kiagiadakis@collabora.com> Date: Mon, 15 Feb 2021 19:48:06 +0200 Subject: [PATCH] config: make the monitor properties & rules available in global tables This allows altering monitor properties or adding rules in different lua files that get loaded before 90-enable*.lua --- src/config/config.lua.d/30-alsa-monitor.lua | 14 ++++++++------ src/config/config.lua.d/30-bluez-monitor.lua | 12 +++++++----- src/config/config.lua.d/30-v4l2-monitor.lua | 12 +++++++----- src/config/config.lua.d/90-enable-audio-all.lua | 4 ++-- src/config/config.lua.d/90-enable-video.lua | 2 +- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/config/config.lua.d/30-alsa-monitor.lua b/src/config/config.lua.d/30-alsa-monitor.lua index b6633d72..df667555 100644 --- a/src/config/config.lua.d/30-alsa-monitor.lua +++ b/src/config/config.lua.d/30-alsa-monitor.lua @@ -1,6 +1,8 @@ -- ALSA monitor config file -- -local properties = { +alsa_monitor = {} + +alsa_monitor.properties = { -- Create a JACK device. This is not enabled by default because -- it requires that the PipeWire JACK replacement libraries are -- not used by the session manager, in order to be able to @@ -13,7 +15,7 @@ local properties = { --["alsa.reserve.application-name"] = "WirePlumber", } -local rules = { +alsa_monitor.rules = { -- An array of matches/actions to evaluate. { -- Rules for matching a device or node. It is an array of @@ -96,14 +98,14 @@ local rules = { } } -function enable_alsa() +function alsa_monitor.enable() -- The "reserve-device" module needs to be loaded for reservation to work - if properties["alsa.reserve"] then + if alsa_monitor.properties["alsa.reserve"] then load_module("reserve-device") end load_monitor("alsa", { - properties = properties, - rules = rules, + properties = alsa_monitor.properties, + rules = alsa_monitor.rules, }) end diff --git a/src/config/config.lua.d/30-bluez-monitor.lua b/src/config/config.lua.d/30-bluez-monitor.lua index 7cb2e530..b8788b5d 100644 --- a/src/config/config.lua.d/30-bluez-monitor.lua +++ b/src/config/config.lua.d/30-bluez-monitor.lua @@ -1,6 +1,8 @@ -- Bluez monitor config file -- -local properties = { +bluez_monitor = {} + +bluez_monitor.properties = { -- MSBC is not expected to work on all headset + adapter combinations. --["bluez5.msbc-support"] = true, --["bluez5.sbc-xq-support"] = true, @@ -19,7 +21,7 @@ local properties = { --["bluez5.codecs"] = "[ sbc aac ldac aptx aptx_hd ]", } -local rules = { +bluez_monitor.rules = { -- An array of matches/actions to evaluate. { -- Rules for matching a device or node. It is an array of @@ -59,9 +61,9 @@ local rules = { }, } -function enable_bluetooth() +function bluez_monitor.enable() load_monitor("bluez5", { - properties = properties, - rules = rules, + properties = bluez_monitor.properties, + rules = bluez_monitor.rules, }) end diff --git a/src/config/config.lua.d/30-v4l2-monitor.lua b/src/config/config.lua.d/30-v4l2-monitor.lua index 45db9e36..c3f1e782 100644 --- a/src/config/config.lua.d/30-v4l2-monitor.lua +++ b/src/config/config.lua.d/30-v4l2-monitor.lua @@ -1,8 +1,10 @@ -- V4L2 monitor config file -- -local properties = { } +v4l2_monitor = {} -local rules = { +v4l2_monitor.properties = { } + +v4l2_monitor.rules = { -- An array of matches/actions to evaluate. { -- Rules for matching a device or node. It is an array of @@ -39,9 +41,9 @@ local rules = { }, } -function enable_v4l2() +function v4l2_monitor.enable() load_monitor("v4l2", { - properties = properties, - rules = rules, + properties = v4l2_monitor.properties, + rules = v4l2_monitor.rules, }) end diff --git a/src/config/config.lua.d/90-enable-audio-all.lua b/src/config/config.lua.d/90-enable-audio-all.lua index b4dad7a1..b851040a 100644 --- a/src/config/config.lua.d/90-enable-audio-all.lua +++ b/src/config/config.lua.d/90-enable-audio-all.lua @@ -1,3 +1,3 @@ enable_audio() -enable_alsa() -enable_bluetooth() +alsa_monitor.enable() +bluez_monitor.enable() diff --git a/src/config/config.lua.d/90-enable-video.lua b/src/config/config.lua.d/90-enable-video.lua index ed904655..a12d7437 100644 --- a/src/config/config.lua.d/90-enable-video.lua +++ b/src/config/config.lua.d/90-enable-video.lua @@ -1 +1 @@ -enable_v4l2() +v4l2_monitor.enable() -- GitLab