3 -- This script mutes all ALSA sinks when the "suspend.playback" metadata
4 -- key is set to 1; compliments pipewire-ic-ipc and the respective support
5 -- for handling "suspend.playback" in the policy scripts
7 -- Copyright © 2021 Collabora Ltd.
8 -- @author George Kiagiadakis <george.kiagiadakis@collabora.com>
10 -- SPDX-License-Identifier: MIT
12 mixer_api = Plugin.find("mixer-api")
14 nodes_om = ObjectManager {
15 Interest { type = "node",
16 Constraint { "media.class", "matches", "Audio/Sink" },
17 Constraint { "object.path", "matches", "alsa:pcm:*" },
21 metadata_om = ObjectManager {
22 Interest { type = "metadata",
23 Constraint { "metadata.name", "=", "default" },
27 metadata_om:connect("object-added", function (om, metadata)
28 metadata:connect("changed", function (m, subject, key, t, value)
29 if key == "suspend.playback" then
30 local suspended = (value == "1")
32 Log.info(string.format("%s ALSA nodes for IC sound",
33 suspended and "muting" or "unmuting"))
35 for n in nodes_om:iterate() do
36 mixer_api:call("set-volume", n["bound-id"], {
45 metadata_om:activate()