From bbd23fa3e3a4e13c86bf37b36e7d19d8dcaff771 Mon Sep 17 00:00:00 2001 From: mazunki Date: Wed, 12 Jan 2022 12:13:08 +0100 Subject: [PATCH 10/14] added support for disabling nodes and devices through conf --- src/config/main.lua.d/50-alsa-config.lua | 13 +++++++++++++ src/scripts/monitors/alsa.lua | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/config/main.lua.d/50-alsa-config.lua b/src/config/main.lua.d/50-alsa-config.lua index 9259cf5..23f8ca1 100644 --- a/src/config/main.lua.d/50-alsa-config.lua +++ b/src/config/main.lua.d/50-alsa-config.lua @@ -17,6 +17,19 @@ alsa_monitor.properties = { alsa_monitor.rules = { -- An array of matches/actions to evaluate. + -- + -- If you want to disable some devices or nodes, you can apply properties per device as the following example. + -- The name can be found by running pw-cli ls Device, or pw-cli dump Device + --{ + -- matches = { + -- { + -- { "device.name", "matches", "name_of_some_disabled_card" }, + -- }, + -- }, + -- apply_properties = { + -- ["device.disabled"] = true, + -- }, + --} { -- Rules for matching a device or node. It is an array of -- properties that all need to match the regexp. If any of the diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua index 8d297c1..c917a5c 100644 --- a/src/scripts/monitors/alsa.lua +++ b/src/scripts/monitors/alsa.lua @@ -168,6 +168,9 @@ function createNode(parent, id, type, factory, properties) -- apply properties from config.rules rulesApplyProperties(properties) + if properties["node.disabled"] then + return + end -- create the node local node = Node("adapter", properties) @@ -254,6 +257,9 @@ function prepareDevice(parent, id, type, factory, properties) -- apply properties from config.rules rulesApplyProperties(properties) + if properties["device.disabled"] then + return + end -- override the device factory to use ACP if properties["api.alsa.use-acp"] then -- 2.34.1