From 28a422968191278640436ca1b092baeada75e262 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Tue, 27 Apr 2021 19:50:38 +0300 Subject: [PATCH] config: unify config and config-split After all, we can just load multiple lua config files/directories from a single .conf file and so have both styles available for the user to choose at runtime --- src/{config-split => config}/bluetooth.conf | 0 .../bluetooth.lua.d/00-functions.lua | 0 .../bluetooth.lua.d/30-bluez-monitor.lua | 0 .../bluetooth.lua.d/50-bluez-config.lua | 0 .../bluetooth.lua.d/90-enable-all.lua | 0 .../common/00-functions.lua | 0 src/config/config.lua | 53 --------- src/config/config.lua.d/10-default-policy.lua | 86 -------------- src/config/config.lua.d/20-default-access.lua | 28 ----- src/config/config.lua.d/30-alsa-monitor.lua | 111 ------------------ src/config/config.lua.d/30-bluez-monitor.lua | 80 ------------- src/config/config.lua.d/30-v4l2-monitor.lua | 49 -------- .../config.lua.d/90-enable-audio-all.lua | 6 - .../config.lua.d/90-enable-default-policy.lua | 1 - src/config/config.lua.d/90-enable-video.lua | 1 - src/{config-split => config}/main.conf | 0 .../main.lua.d/00-functions.lua | 0 .../main.lua.d/20-default-access.lua | 0 .../main.lua.d/30-alsa-monitor.lua | 0 .../main.lua.d/30-v4l2-monitor.lua | 0 .../main.lua.d/40-device-defaults.lua | 0 .../main.lua.d/50-alsa-config.lua | 0 .../main.lua.d/50-default-access-config.lua | 0 .../main.lua.d/50-v4l2-config.lua | 0 .../main.lua.d/90-enable-all.lua | 0 src/{config-split => config}/policy.conf | 0 .../policy.lua.d/00-functions.lua | 0 .../policy.lua.d/10-default-policy.lua | 0 .../policy.lua.d/50-endpoints-config.lua | 0 .../policy.lua.d/90-enable-all.lua | 0 src/config/wireplumber.conf | 7 +- 31 files changed, 5 insertions(+), 417 deletions(-) rename src/{config-split => config}/bluetooth.conf (100%) rename src/{config-split => config}/bluetooth.lua.d/00-functions.lua (100%) rename src/{config-split => config}/bluetooth.lua.d/30-bluez-monitor.lua (100%) rename src/{config-split => config}/bluetooth.lua.d/50-bluez-config.lua (100%) rename src/{config-split => config}/bluetooth.lua.d/90-enable-all.lua (100%) rename src/{config-split => config}/common/00-functions.lua (100%) delete mode 100644 src/config/config.lua delete mode 100644 src/config/config.lua.d/10-default-policy.lua delete mode 100644 src/config/config.lua.d/20-default-access.lua delete mode 100644 src/config/config.lua.d/30-alsa-monitor.lua delete mode 100644 src/config/config.lua.d/30-bluez-monitor.lua delete mode 100644 src/config/config.lua.d/30-v4l2-monitor.lua delete mode 100644 src/config/config.lua.d/90-enable-audio-all.lua delete mode 100644 src/config/config.lua.d/90-enable-default-policy.lua delete mode 100644 src/config/config.lua.d/90-enable-video.lua rename src/{config-split => config}/main.conf (100%) rename src/{config-split => config}/main.lua.d/00-functions.lua (100%) rename src/{config-split => config}/main.lua.d/20-default-access.lua (100%) rename src/{config-split => config}/main.lua.d/30-alsa-monitor.lua (100%) rename src/{config-split => config}/main.lua.d/30-v4l2-monitor.lua (100%) rename src/{config-split => config}/main.lua.d/40-device-defaults.lua (100%) rename src/{config-split => config}/main.lua.d/50-alsa-config.lua (100%) rename src/{config-split => config}/main.lua.d/50-default-access-config.lua (100%) rename src/{config-split => config}/main.lua.d/50-v4l2-config.lua (100%) rename src/{config-split => config}/main.lua.d/90-enable-all.lua (100%) rename src/{config-split => config}/policy.conf (100%) rename src/{config-split => config}/policy.lua.d/00-functions.lua (100%) rename src/{config-split => config}/policy.lua.d/10-default-policy.lua (100%) rename src/{config-split => config}/policy.lua.d/50-endpoints-config.lua (100%) rename src/{config-split => config}/policy.lua.d/90-enable-all.lua (100%) diff --git a/src/config-split/bluetooth.conf b/src/config/bluetooth.conf similarity index 100% rename from src/config-split/bluetooth.conf rename to src/config/bluetooth.conf diff --git a/src/config-split/bluetooth.lua.d/00-functions.lua b/src/config/bluetooth.lua.d/00-functions.lua similarity index 100% rename from src/config-split/bluetooth.lua.d/00-functions.lua rename to src/config/bluetooth.lua.d/00-functions.lua diff --git a/src/config-split/bluetooth.lua.d/30-bluez-monitor.lua b/src/config/bluetooth.lua.d/30-bluez-monitor.lua similarity index 100% rename from src/config-split/bluetooth.lua.d/30-bluez-monitor.lua rename to src/config/bluetooth.lua.d/30-bluez-monitor.lua diff --git a/src/config-split/bluetooth.lua.d/50-bluez-config.lua b/src/config/bluetooth.lua.d/50-bluez-config.lua similarity index 100% rename from src/config-split/bluetooth.lua.d/50-bluez-config.lua rename to src/config/bluetooth.lua.d/50-bluez-config.lua diff --git a/src/config-split/bluetooth.lua.d/90-enable-all.lua b/src/config/bluetooth.lua.d/90-enable-all.lua similarity index 100% rename from src/config-split/bluetooth.lua.d/90-enable-all.lua rename to src/config/bluetooth.lua.d/90-enable-all.lua diff --git a/src/config-split/common/00-functions.lua b/src/config/common/00-functions.lua similarity index 100% rename from src/config-split/common/00-functions.lua rename to src/config/common/00-functions.lua diff --git a/src/config/config.lua b/src/config/config.lua deleted file mode 100644 index 3be36a77..00000000 --- a/src/config/config.lua +++ /dev/null @@ -1,53 +0,0 @@ -components = {} - -function load_module(m) - if not components[m] then - components[m] = { "libwireplumber-module-" .. m, type = "module" } - end -end - -function load_pw_module(m) - if not components[m] then - components[m] = { "libpipewire-module-" .. m, type = "pw_module" } - end -end - -function load_script(s, a) - if not components[s] then - components[s] = { s, type = "script/lua", args = a } - end -end - -function load_monitor(s, a) - load_script("monitors/" .. s .. ".lua", a) -end - -function load_access(s, a) - load_script("access/access-" .. s .. ".lua", a) -end - --- Additional PipeWire modules can be loaded in WirePlumber like this. --- libpipewire already loads all the modules that we normally need, though. --- module-spa-node-factory may be needed if you want to use a monitor with --- LocalNode and the "spa-node-factory" factory --- ("adapter" is loaded by default, but "spa-node-factory" isn't) --- --- load_pw_module ("spa-node-factory") - --- Automatically suspends idle nodes after 3 seconds -load_script("suspend-node.lua") - --- Automatically sets device profiles to 'On' -load_module("device-activation") - --- Automatically save and restore default routes -load_module("default-routes") - --- Implements storing metadata about objects in RAM -load_module("metadata") - --- Enables saving and restoring default nodes -load_module("default-nodes") - --- API to access default nodes from scripts -load_module("default-nodes-api") diff --git a/src/config/config.lua.d/10-default-policy.lua b/src/config/config.lua.d/10-default-policy.lua deleted file mode 100644 index 4d7d08ae..00000000 --- a/src/config/config.lua.d/10-default-policy.lua +++ /dev/null @@ -1,86 +0,0 @@ --- Default policy config file -- - -default_policy = {} - -default_policy.sessions = { - -- [session name] = { session properties } - ["audio"] = { ["media.type"] = "Audio" }, - ["video"] = { ["media.type"] = "Video" }, -} - -default_policy.endpoints = { - -- [endpoint name] = { endpoint properties } ---[[ - ["endpoint.multimedia"] = { - ["media.class"] = "Audio/Sink", - ["role"] = "Multimedia", - }, - ["endpoint.notifications"] = { - ["media.class"] = "Audio/Sink", - ["role"] = "Notification", - }, - ["endpoint.alert"] = { - ["media.class"] = "Audio/Sink", - ["role"] = "Alert", - }, ---]] -} - -default_policy.policy = { - ["move"] = true, -- moves session items when metadata target.node changes - ["follow"] = true, -- moves session items to the default device when it has changed - ---[[ - ["roles"] = { - ["Multimedia"] = { - ["alias"] = { "Movie", "Music", "Game" }, - ["priority"] = 10, - ["action.default"] = "mix", - }, - ["Notification"] = { - ["priority"] = 20, - ["action.default"] = "duck", - ["action.Notification"] = "mix", - }, - ["Alert"] = { - ["priority"] = 30, - ["action.default"] = "cork", - ["action.Alert"] = "mix", - }, - }, ---]] -} - -function default_policy.enable() - -- Session item factories, building blocks for the session management graph - -- Do not disable these unless you really know what you are doing - load_module("si-node") - load_module("si-audio-adapter") - load_module("si-standard-link") - load_module("si-audio-endpoint") - - -- API to access default nodes from scripts - load_module("default-nodes-api") - - -- API to access mixer controls, needed for volume ducking - --load_module("mixer-api") - - -- Create sessions statically at startup - load_script("static-sessions.lua", default_policy.sessions) - - -- Create endpoints statically at startup - load_script("static-endpoints.lua", default_policy.endpoints) - - -- Create items for nodes that appear in the graph - load_script("create-item.lua") - - -- Link nodes to each other to make media flow in the graph - load_script("policy-node.lua", default_policy.policy) - - -- Link client nodes with endpoints to make media flow in the graph - load_script("policy-endpoint-client.lua", default_policy.policy) - load_script("policy-endpoint-client-links.lua", default_policy.policy) - - -- Link endpoints with device nodes to make media flow in the graph - load_script("policy-endpoint-device.lua", default_policy.policy) -end diff --git a/src/config/config.lua.d/20-default-access.lua b/src/config/config.lua.d/20-default-access.lua deleted file mode 100644 index 09aa8da4..00000000 --- a/src/config/config.lua.d/20-default-access.lua +++ /dev/null @@ -1,28 +0,0 @@ -default_access = {} - -default_access.properties = { - ["enable-flatpak-portal"] = true, -} - -default_access.rules = { - { - matches = { - { - { "pipewire.access", "=", "flatpak" }, - }, - }, - default_permissions = "rx", - }, -} - -function default_access.enable() - load_access("default", { - rules = default_access.rules - }) - - if default_access.properties["enable-flatpak-portal"] then - -- Enables portal permissions via org.freedesktop.impl.portal.PermissionStore - load_module("portal-permissionstore") - load_access("portal") - end -end diff --git a/src/config/config.lua.d/30-alsa-monitor.lua b/src/config/config.lua.d/30-alsa-monitor.lua deleted file mode 100644 index df667555..00000000 --- a/src/config/config.lua.d/30-alsa-monitor.lua +++ /dev/null @@ -1,111 +0,0 @@ --- ALSA monitor config file -- - -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 - -- connect to the real JACK server. - --["alsa.jack-device"] = false, - - -- Reserve devices via org.freedesktop.ReserveDevice1 on D-Bus - ["alsa.reserve"] = true, - --["alsa.reserve.priority"] = -20, - --["alsa.reserve.application-name"] = "WirePlumber", -} - -alsa_monitor.rules = { - -- An array of matches/actions to evaluate. - { - -- Rules for matching a device or node. It is an array of - -- properties that all need to match the regexp. If any of the - -- matches work, the actions are executed for the object. - matches = { - { - -- This matches all cards. - { "device.name", "matches", "alsa_card.*" }, - }, - }, - -- Apply properties on the matched object. - apply_properties = { - -- Use ALSA-Card-Profile devices. They use UCM or the profile - -- configuration to configure the device and mixer settings. - ["api.alsa.use-acp"] = true, - - -- Use UCM instead of profile when available. Can be - -- disabled to skip trying to use the UCM profile. - --["api.alsa.use-ucm"] = true, - - -- Don't use the hardware mixer for volume control. It - -- will only use software volume. The mixer is still used - -- to mute unused paths based on the selected port. - --["api.alsa.soft-mixer"] = false, - - -- Ignore decibel settings of the driver. Can be used to - -- work around buggy drivers that report wrong values. - --["api.alsa.ignore-dB"] = false, - - -- The profile set to use for the device. Usually this is - -- "default.conf" but can be changed with a udev rule or here. - --["device.profile-set"] = "profileset-name", - - -- The default active profile. Is by default set to "Off". - --["device.profile"] = "default profile name", - - -- Automatically select the best profile. This is the - -- highest priority available profile. This is disabled - -- here and instead implemented in the session manager - -- where it can save and load previous preferences. - ["api.acp.auto-profile"] = false, - - -- Automatically switch to the highest priority available port. - -- This is disabled here and implemented in the session manager instead. - ["api.acp.auto-port"] = false, - - -- Other properties can be set here. - --["device.nick"] = "My Device", - }, - }, - { - matches = { - { - -- Matches all sources. - { "node.name", "matches", "alsa_input.*" }, - }, - { - -- Matches all sinks. - { "node.name", "matches", "alsa_output.*" }, - }, - }, - apply_properties = { - --["node.nick"] = "My Node", - --["priority.driver"] = 100, - --["priority.session"] = 100, - --["node.pause-on-idle"] = false, - --["resample.quality"] = 4, - --["channelmix.normalize"] = false, - --["channelmix.mix-lfe"] = false, - --["audio.channels"] = 2, - --["audio.format"] = "S16LE", - --["audio.rate"] = 44100, - --["audio.position"] = "FL,FR", - --["api.alsa.period-size"] = 1024, - --["api.alsa.headroom"] = 0, - --["api.alsa.disable-mmap"] = false, - --["api.alsa.disable-batch"] = false, - } - } -} - -function alsa_monitor.enable() - -- The "reserve-device" module needs to be loaded for reservation to work - if alsa_monitor.properties["alsa.reserve"] then - load_module("reserve-device") - end - - load_monitor("alsa", { - 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 deleted file mode 100644 index 1e6cc2f7..00000000 --- a/src/config/config.lua.d/30-bluez-monitor.lua +++ /dev/null @@ -1,80 +0,0 @@ --- Bluez monitor config file -- - -bluez_monitor = {} - -bluez_monitor.properties = { - --["bluez5.sbc-xq-support"] = true, - - -- Enabled headset roles (default: [ hsp_hs hfp_ag ]), this - -- property only applies to native backend. Currently some headsets - -- (Sony WH-1000XM3) are not working with both hsp_ag and hfp_ag - -- enabled, disable either hsp_ag or hfp_ag to work around it. - -- - -- Supported headset roles: hsp_hs (HSP Headset), - -- hsp_ag (HSP Audio Gateway), - -- hfp_hf (HFP Hands-Free), - -- hfp_ag (HFP Audio Gateway) - --["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]", - - -- Enabled A2DP codecs (default: all). - --["bluez5.codecs"] = "[ sbc aac ldac aptx aptx_hd ]", -} - -bluez_monitor.rules = { - -- An array of matches/actions to evaluate. - { - -- Rules for matching a device or node. It is an array of - -- properties that all need to match the regexp. If any of the - -- matches work, the actions are executed for the object. - matches = { - { - -- This matches all cards. - { "device.name", "matches", "bluez_card.*" }, - }, - }, - -- Apply properties on the matched object. - apply_properties = { - -- Autoconnect device profiles, disabled by default - -- if the property is not specified. - ["bluez5.reconnect-profiles"] = "[ hfp_hf hsp_hs a2dp_sink ]", - - -- MSBC is not expected to work on all headset + adapter combinations. - --["bluez5.msbc-support"] = false, - - -- LDAC encoding quality - -- Available values: auto (Adaptive Bitrate, default) - -- hq (High Quality, 990/909kbps) - -- sq (Standard Quality, 660/606kbps) - -- mq (Mobile use Quality, 330/303kbps) - --["bluez5.a2dp.ldac.quality"] = "auto", - }, - }, - { - matches = { - { - -- Matches all sources. - { "node.name", "matches", "bluez_input.*" }, - }, - { - -- Matches all sinks. - { "node.name", "matches", "bluez_output.*" }, - }, - }, - apply_properties = { - --["node.nick"] = "My Node", - --["priority.driver"] = 100, - --["priority.session"] = 100, - --["node.pause-on-idle"] = false, - --["resample.quality"] = 4, - --["channelmix.normalize"] = false, - --["channelmix.mix-lfe"] = false, - }, - }, -} - -function bluez_monitor.enable() - load_monitor("bluez", { - 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 deleted file mode 100644 index c3f1e782..00000000 --- a/src/config/config.lua.d/30-v4l2-monitor.lua +++ /dev/null @@ -1,49 +0,0 @@ --- V4L2 monitor config file -- - -v4l2_monitor = {} - -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 - -- properties that all need to match the regexp. If any of the - -- matches work, the actions are executed for the object. - matches = { - { - -- This matches all cards. - { "device.name", "matches", "v4l2_device.*" }, - }, - }, - -- Apply properties on the matched object. - apply_properties = { - -- ["device.nick"] = "My Device", - }, - }, - { - matches = { - { - -- Matches all sources. - { "node.name", "matches", "v4l2_input.*" }, - }, - { - -- Matches all sinks. - { "node.name", "matches", "v4l2_output.*" }, - }, - }, - apply_properties = { - --["node.nick"] = "My Node", - --["priority.driver"] = 100, - --["priority.session"] = 100, - --["node.pause-on-idle"] = false, - }, - }, -} - -function v4l2_monitor.enable() - load_monitor("v4l2", { - 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 deleted file mode 100644 index d1167478..00000000 --- a/src/config/config.lua.d/90-enable-audio-all.lua +++ /dev/null @@ -1,6 +0,0 @@ --- Enable local & bluetooth audio devices -alsa_monitor.enable() -bluez_monitor.enable() - --- Enables functionality to save and restore default device profiles -load_module("default-profile") diff --git a/src/config/config.lua.d/90-enable-default-policy.lua b/src/config/config.lua.d/90-enable-default-policy.lua deleted file mode 100644 index c20e23ab..00000000 --- a/src/config/config.lua.d/90-enable-default-policy.lua +++ /dev/null @@ -1 +0,0 @@ -default_policy.enable() diff --git a/src/config/config.lua.d/90-enable-video.lua b/src/config/config.lua.d/90-enable-video.lua deleted file mode 100644 index a12d7437..00000000 --- a/src/config/config.lua.d/90-enable-video.lua +++ /dev/null @@ -1 +0,0 @@ -v4l2_monitor.enable() diff --git a/src/config-split/main.conf b/src/config/main.conf similarity index 100% rename from src/config-split/main.conf rename to src/config/main.conf diff --git a/src/config-split/main.lua.d/00-functions.lua b/src/config/main.lua.d/00-functions.lua similarity index 100% rename from src/config-split/main.lua.d/00-functions.lua rename to src/config/main.lua.d/00-functions.lua diff --git a/src/config-split/main.lua.d/20-default-access.lua b/src/config/main.lua.d/20-default-access.lua similarity index 100% rename from src/config-split/main.lua.d/20-default-access.lua rename to src/config/main.lua.d/20-default-access.lua diff --git a/src/config-split/main.lua.d/30-alsa-monitor.lua b/src/config/main.lua.d/30-alsa-monitor.lua similarity index 100% rename from src/config-split/main.lua.d/30-alsa-monitor.lua rename to src/config/main.lua.d/30-alsa-monitor.lua diff --git a/src/config-split/main.lua.d/30-v4l2-monitor.lua b/src/config/main.lua.d/30-v4l2-monitor.lua similarity index 100% rename from src/config-split/main.lua.d/30-v4l2-monitor.lua rename to src/config/main.lua.d/30-v4l2-monitor.lua diff --git a/src/config-split/main.lua.d/40-device-defaults.lua b/src/config/main.lua.d/40-device-defaults.lua similarity index 100% rename from src/config-split/main.lua.d/40-device-defaults.lua rename to src/config/main.lua.d/40-device-defaults.lua diff --git a/src/config-split/main.lua.d/50-alsa-config.lua b/src/config/main.lua.d/50-alsa-config.lua similarity index 100% rename from src/config-split/main.lua.d/50-alsa-config.lua rename to src/config/main.lua.d/50-alsa-config.lua diff --git a/src/config-split/main.lua.d/50-default-access-config.lua b/src/config/main.lua.d/50-default-access-config.lua similarity index 100% rename from src/config-split/main.lua.d/50-default-access-config.lua rename to src/config/main.lua.d/50-default-access-config.lua diff --git a/src/config-split/main.lua.d/50-v4l2-config.lua b/src/config/main.lua.d/50-v4l2-config.lua similarity index 100% rename from src/config-split/main.lua.d/50-v4l2-config.lua rename to src/config/main.lua.d/50-v4l2-config.lua diff --git a/src/config-split/main.lua.d/90-enable-all.lua b/src/config/main.lua.d/90-enable-all.lua similarity index 100% rename from src/config-split/main.lua.d/90-enable-all.lua rename to src/config/main.lua.d/90-enable-all.lua diff --git a/src/config-split/policy.conf b/src/config/policy.conf similarity index 100% rename from src/config-split/policy.conf rename to src/config/policy.conf diff --git a/src/config-split/policy.lua.d/00-functions.lua b/src/config/policy.lua.d/00-functions.lua similarity index 100% rename from src/config-split/policy.lua.d/00-functions.lua rename to src/config/policy.lua.d/00-functions.lua diff --git a/src/config-split/policy.lua.d/10-default-policy.lua b/src/config/policy.lua.d/10-default-policy.lua similarity index 100% rename from src/config-split/policy.lua.d/10-default-policy.lua rename to src/config/policy.lua.d/10-default-policy.lua diff --git a/src/config-split/policy.lua.d/50-endpoints-config.lua b/src/config/policy.lua.d/50-endpoints-config.lua similarity index 100% rename from src/config-split/policy.lua.d/50-endpoints-config.lua rename to src/config/policy.lua.d/50-endpoints-config.lua diff --git a/src/config-split/policy.lua.d/90-enable-all.lua b/src/config/policy.lua.d/90-enable-all.lua similarity index 100% rename from src/config-split/policy.lua.d/90-enable-all.lua rename to src/config/policy.lua.d/90-enable-all.lua diff --git a/src/config/wireplumber.conf b/src/config/wireplumber.conf index b26c5896..0ac65c73 100644 --- a/src/config/wireplumber.conf +++ b/src/config/wireplumber.conf @@ -6,6 +6,7 @@ context.properties = { #application.name = WirePlumber log.level = 2 wireplumber.script-engine = lua-scripting + #wireplumber.export-core = true #mem.mlock-all = false #support.dbus = true @@ -70,7 +71,9 @@ wireplumber.components = [ # The lua scripting engine { name = libwireplumber-module-lua-scripting, type = module } - # The lua configuration file + # The lua configuration file(s) # Other components are loaded from there - { name = config.lua, type = config/lua } + { name = main.lua, type = config/lua } + { name = policy.lua, type = config/lua } + { name = bluetooth.lua, type = config/lua } ]