mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-04 08:30:31 +01:00
scripts: switch to using JsonUtils.match_rules_apply_properties()
Note: this requires all existing config files to be modified to follow pipewire's rules syntax, with an "actions" object wrapping the "update-props" object.
This commit is contained in:
parent
fbecc50319
commit
299e671ffa
9 changed files with 189 additions and 157 deletions
|
|
@ -16,9 +16,11 @@ wireplumber.settings = {
|
|||
media.category = "Manager"
|
||||
}
|
||||
]
|
||||
update-props = {
|
||||
access = "flatpak-manager"
|
||||
default_permissions = "all",
|
||||
actions = {
|
||||
update-props = {
|
||||
access = "flatpak-manager"
|
||||
default_permissions = "all",
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
|
|
@ -27,8 +29,10 @@ wireplumber.settings = {
|
|||
access = "flatpak"
|
||||
}
|
||||
]
|
||||
update-props = {
|
||||
default_permissions = "rx"
|
||||
actions = {
|
||||
update-props = {
|
||||
default_permissions = "rx"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
|
|
@ -37,8 +41,10 @@ wireplumber.settings = {
|
|||
access = "restricted"
|
||||
}
|
||||
]
|
||||
update-props = {
|
||||
default_permissions = "rx"
|
||||
actions = {
|
||||
update-props = {
|
||||
default_permissions = "rx"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
|
|
@ -47,8 +53,10 @@ wireplumber.settings = {
|
|||
access = "default"
|
||||
}
|
||||
]
|
||||
update-props = {
|
||||
default_permissions = "all"
|
||||
actions = {
|
||||
update-props = {
|
||||
default_permissions = "all"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -59,9 +59,11 @@ monitor.alsa.rules = [
|
|||
# device.name = "~alsa_card.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# api.alsa.use-acp = true
|
||||
# api.acp.auto-port = false
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# api.alsa.use-acp = true
|
||||
# api.acp.auto-port = false
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
|
@ -73,46 +75,48 @@ monitor.alsa.rules = [
|
|||
# device.name = "~alsa_card.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# ## Use ALSA-Card-Profile devices. They use UCM or the profile
|
||||
# ## configuration to configure the device and mixer settings.
|
||||
# api.alsa.use-acp = false
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# ## Use ALSA-Card-Profile devices. They use UCM or the profile
|
||||
# ## configuration to configure the device and mixer settings.
|
||||
# api.alsa.use-acp = false
|
||||
#
|
||||
# ## Use UCM instead of profile when available. Can be
|
||||
# ## disabled to skip trying to use the UCM profile.
|
||||
# api.alsa.use-ucm = false
|
||||
# ## Use UCM instead of profile when available. Can be
|
||||
# ## disabled to skip trying to use the UCM profile.
|
||||
# api.alsa.use-ucm = false
|
||||
#
|
||||
# ## 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
|
||||
# ## 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
|
||||
# ## 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 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"
|
||||
# ## 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 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 = true
|
||||
# ## Automatically switch to the highest priority available port.
|
||||
# ## This is disabled here and implemented in the session manager instead.
|
||||
# api.acp.auto-port = true
|
||||
#
|
||||
# ## Other properties can be set here.
|
||||
# device.nick = "My Device"
|
||||
# ## Other properties can be set here.
|
||||
# device.nick = "My Device"
|
||||
#
|
||||
# ## Whether to disable the device or not
|
||||
# device.disabled = false
|
||||
# ## Whether to disable the device or not
|
||||
# device.disabled = false
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
|
@ -128,49 +132,51 @@ monitor.alsa.rules = [
|
|||
# node.name = "~alsa_output.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# node.description = "My Node Description"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# monitor.channel-volumes = false
|
||||
# resample.quality = 4
|
||||
# resample.disable = false
|
||||
# channelmix.normalize = false
|
||||
# channelmix.mix-lfe = false
|
||||
# channelmix.upmix = true
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# node.description = "My Node Description"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# monitor.channel-volumes = false
|
||||
# resample.quality = 4
|
||||
# resample.disable = false
|
||||
# channelmix.normalize = false
|
||||
# channelmix.mix-lfe = false
|
||||
# channelmix.upmix = true
|
||||
#
|
||||
# ## only "psd", "none" or "simple" values are accepted
|
||||
# channelmix.upmix-method = "psd"
|
||||
# ## only "psd", "none" or "simple" values are accepted
|
||||
# channelmix.upmix-method = "psd"
|
||||
#
|
||||
# channelmix.lfe-cutoff = 150
|
||||
# channelmix.fc-cutoff = 12000
|
||||
# channelmix.rear-delay = 12.0
|
||||
# channelmix.stereo-widen = 0.0
|
||||
# channelmix.hilbert-taps = 0
|
||||
# channelmix.disable = false
|
||||
# dither.noise = 0
|
||||
# dither.method = "none"
|
||||
# audio.channels = 2
|
||||
# audio.format = "S16LE"
|
||||
# audio.rate = 44100
|
||||
# audio.allowed-rates = "32000,96000"
|
||||
# audio.position = "FLFR"
|
||||
# api.alsa.period-size = 1024
|
||||
# api.alsa.period-num = 2
|
||||
# api.alsa.headroom = 0
|
||||
# api.alsa.start-delay = 0
|
||||
# api.alsa.disable-mmap = false
|
||||
# api.alsa.disable-batch = false
|
||||
# api.alsa.use-chmap = false
|
||||
# api.alsa.multirate = true
|
||||
# latency.internal.rate = 0
|
||||
# latency.internal.ns = 0
|
||||
# clock.name = "api.alsa.0"
|
||||
# channelmix.lfe-cutoff = 150
|
||||
# channelmix.fc-cutoff = 12000
|
||||
# channelmix.rear-delay = 12.0
|
||||
# channelmix.stereo-widen = 0.0
|
||||
# channelmix.hilbert-taps = 0
|
||||
# channelmix.disable = false
|
||||
# dither.noise = 0
|
||||
# dither.method = "none"
|
||||
# audio.channels = 2
|
||||
# audio.format = "S16LE"
|
||||
# audio.rate = 44100
|
||||
# audio.allowed-rates = "32000,96000"
|
||||
# audio.position = "FLFR"
|
||||
# api.alsa.period-size = 1024
|
||||
# api.alsa.period-num = 2
|
||||
# api.alsa.headroom = 0
|
||||
# api.alsa.start-delay = 0
|
||||
# api.alsa.disable-mmap = false
|
||||
# api.alsa.disable-batch = false
|
||||
# api.alsa.use-chmap = false
|
||||
# api.alsa.multirate = true
|
||||
# latency.internal.rate = 0
|
||||
# latency.internal.ns = 0
|
||||
# clock.name = "api.alsa.0"
|
||||
#
|
||||
# ## 0 disables suspend
|
||||
# session.suspend-timeout-seconds = 5
|
||||
# ## 0 disables suspend
|
||||
# session.suspend-timeout-seconds = 5
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
|
|
|
|||
|
|
@ -102,8 +102,10 @@ monitor.bluetooth.rules = [
|
|||
# device.name = "~bluez_card.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# bluez5.auto-connect = "[ hfp_hf hsp_hs a2dp_sink ]"
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# bluez5.auto-connect = "[ hfp_hf hsp_hs a2dp_sink ]"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
|
@ -115,33 +117,35 @@ monitor.bluetooth.rules = [
|
|||
# device.name = "~bluez_card.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# ## Auto-connect device profiles on start up or when only partial
|
||||
# ## profiles have connected. Disabled by default if the property
|
||||
# ## is not specified.
|
||||
# bluez5.auto-connect = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]"
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# ## Auto-connect device profiles on start up or when only partial
|
||||
# ## profiles have connected. Disabled by default if the property
|
||||
# ## is not specified.
|
||||
# bluez5.auto-connect = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]"
|
||||
#
|
||||
# ## Hardware volume control (default: [ hfp_ag hsp_ag a2dp_source ])
|
||||
# bluez5.hw-volume = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]"
|
||||
# ## Hardware volume control (default: [ hfp_ag hsp_ag a2dp_source ])
|
||||
# bluez5.hw-volume = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]"
|
||||
#
|
||||
# ## 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"
|
||||
# ## 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"
|
||||
#
|
||||
# ## AAC variable bitrate mode
|
||||
# ## Available values: 0 (cbr, default), 1-5 (quality level)
|
||||
# bluez5.a2dp.aac.bitratemode = 0
|
||||
# ## AAC variable bitrate mode
|
||||
# ## Available values: 0 (cbr, default), 1-5 (quality level)
|
||||
# bluez5.a2dp.aac.bitratemode = 0
|
||||
#
|
||||
# ## Profile connected first
|
||||
# ## Available values: a2dp-sink (default), headset-head-unit
|
||||
# device.profile = "a2dp-sink"
|
||||
# ## Profile connected first
|
||||
# ## Available values: a2dp-sink (default), headset-head-unit
|
||||
# device.profile = "a2dp-sink"
|
||||
#
|
||||
# ## Opus Pro Audio encoding mode: audio, voip, lowdelay
|
||||
# bluez5.a2dp.opus.pro.application = "audio"
|
||||
# bluez5.a2dp.opus.pro.bidi.application = "audio"
|
||||
# ## Opus Pro Audio encoding mode: audio, voip, lowdelay
|
||||
# bluez5.a2dp.opus.pro.application = "audio"
|
||||
# bluez5.a2dp.opus.pro.bidi.application = "audio"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
|
@ -157,21 +161,23 @@ monitor.bluetooth.rules = [
|
|||
# node.name = "~bluez_output.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# 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
|
||||
# session.suspend-timeout-seconds = 5
|
||||
# monitor.channel-volumes = false
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# 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
|
||||
# session.suspend-timeout-seconds = 5
|
||||
# monitor.channel-volumes = false
|
||||
#
|
||||
# ## Media source role, "input" or "playback"
|
||||
# ## Defaults to "playback", playing stream to speakers
|
||||
# ## Set to "input" to use as an input for apps
|
||||
# bluez5.media-source-role = "input"
|
||||
# ## Media source role, "input" or "playback"
|
||||
# ## Defaults to "playback", playing stream to speakers
|
||||
# ## Set to "input" to use as an input for apps
|
||||
# bluez5.media-source-role = "input"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
|
|
@ -188,13 +194,15 @@ monitor.bluetooth-midi.rules = [
|
|||
# node.name = "~bluez_midi*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# session.suspend-timeout-seconds = 5
|
||||
# monitor.channel-volumes = false
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# session.suspend-timeout-seconds = 5
|
||||
# monitor.channel-volumes = false
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ monitor.libcamera.rules = [
|
|||
# device.name = "~libcamera_device.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# device.nick = "My Device"
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# device.nick = "My Device"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
|
@ -37,11 +39,13 @@ monitor.libcamera.rules = [
|
|||
# node.name = "~libcamera_output.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@ stream.rules = [
|
|||
# ## Matches all devices
|
||||
# { application.name = "pw-play" }
|
||||
# ]
|
||||
# update-props = {
|
||||
# state.restore-props = false
|
||||
# state.restore-target = false
|
||||
# state.default-channel-volume = 1.0
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# state.restore-props = false
|
||||
# state.restore-target = false
|
||||
# state.default-channel-volume = 1.0
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ monitor.v4l2.rules = [
|
|||
# device.name = "~v4l2_device.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# device.nick = "My Device"
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# device.nick = "My Device"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
|
@ -32,11 +34,13 @@ monitor.v4l2.rules = [
|
|||
# node.name = "~v4l2_output.*"
|
||||
# }
|
||||
# ]
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# node.nick = "My Node"
|
||||
# priority.driver = 100
|
||||
# priority.session = 100
|
||||
# node.pause-on-idle = false
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
|
|
|
|||
|
|
@ -43,8 +43,10 @@ function getDefaultPermissions (properties)
|
|||
end
|
||||
|
||||
function getPermissions (properties)
|
||||
local matched, mprops = Conf.apply_rules ("access.rules", properties)
|
||||
if (matched and mprops["default_permissions"]) then
|
||||
local section = Conf.get_section ("access.rules")
|
||||
local matched, mprops = JsonUtils.match_rules_update_properties (
|
||||
section, properties)
|
||||
if (matched > 0 and mprops["default_permissions"]) then
|
||||
return mprops["default_permissions"], mprops["access"]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -72,15 +72,15 @@ function cutils.get_default_metadata_object ()
|
|||
end
|
||||
|
||||
function cutils.evaluateRulesApplyProperties (properties, name)
|
||||
local matched, mprops = Conf.apply_rules (name, properties)
|
||||
local section = Conf.get_section (name)
|
||||
local matched, mprops = JsonUtils.match_rules_update_properties (
|
||||
section, properties)
|
||||
|
||||
if (matched and mprops) then
|
||||
if (matched > 0 and mprops) then
|
||||
for k, v in pairs (mprops) do
|
||||
properties [k] = v
|
||||
end
|
||||
end
|
||||
|
||||
return matched and mprops
|
||||
end
|
||||
|
||||
-- simple serializer {"foo", "bar"} -> "foo;bar;"
|
||||
|
|
|
|||
|
|
@ -268,11 +268,9 @@ function prepareDevice(parent, id, obj_type, factory, properties)
|
|||
end
|
||||
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
local applied = cutils.evaluateRulesApplyProperties (properties,
|
||||
"monitor.alsa.rules")
|
||||
if not applied then
|
||||
applyDefaultDeviceProperties (properties)
|
||||
end
|
||||
applyDefaultDeviceProperties (properties)
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.alsa.rules")
|
||||
|
||||
if properties ["device.disabled"] then
|
||||
device_names_table [properties ["device.name"]] = nil
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue