mpv: sane-sysvol: fix pipewire mute to reflect onto uosc volume level

ideally it would actually show up as the mute parameter!
This commit is contained in:
2024-04-09 07:08:23 +00:00
parent 8181a0664d
commit c897f4fa4b

View File

@@ -9,7 +9,8 @@ function startswith(superstring, substring)
return superstring:sub(1, substring:len()) == substring return superstring:sub(1, substring:len()) == substring
end end
function strip_prefix(superstring, substring) function strip_prefix(superstring, substring)
return superstring:sub(substring:len()) assert(startswith(superstring, substring))
return superstring:sub(1 + substring:len())
end end
function ltrim(s) function ltrim(s)
@@ -122,7 +123,7 @@ function pwmon_parser_new()
-- which of the *Volumes params we read is unclear. -- which of the *Volumes params we read is unclear.
-- alternative to this is to just detect the change, and then cal wpctl get-volume @DEFAULT_AUDIO_SINK@ -- alternative to this is to just detect the change, and then cal wpctl get-volume @DEFAULT_AUDIO_SINK@
self.in_vol = startswith(line, "Prop: key Spa:Pod:Object:Param:Props:channelVolumes") self.in_vol = startswith(line, "Prop: key Spa:Pod:Object:Param:Props:channelVolumes")
self.in_mute = startswith(line, "Prop: key Spa:Pod:Object:Param:Props:softMute") self.in_mute = startswith(line, "Prop: key Spa:Pod:Object:Param:Props:mute")
msg.trace("parsed `Prop:`", line, self.in_vol) msg.trace("parsed `Prop:`", line, self.in_vol)
elseif line:find("Spa:Enum:Direction:Output", 1, true) and self.in_direction then elseif line:find("Spa:Enum:Direction:Output", 1, true) and self.in_direction then
self.in_output = true self.in_output = true
@@ -130,7 +131,7 @@ function pwmon_parser_new()
value = tonumber(strip_prefix(line, "Float ")) value = tonumber(strip_prefix(line, "Float "))
self:feed_volume(value) self:feed_volume(value)
elseif startswith(line, "Bool ") and self.in_device and self.in_output and self.in_mute then elseif startswith(line, "Bool ") and self.in_device and self.in_output and self.in_mute then
value = tonumber(strip_prefix(line, "Bool ")) == "true" value = strip_prefix(line, "Bool ") == "true"
self:feed_mute(value) self:feed_mute(value)
elseif startswith(line, "properties:") and self.in_device then elseif startswith(line, "properties:") and self.in_device then
self.in_properties = true self.in_properties = true