Support optional "format_muted" setting for audio modules
The alsa and pulseaudio modules now support an optional "format_muted" setting. If provided, it will be used instead of "format" when the audio is muted.
This commit is contained in:
parent
c6e6a03e6d
commit
bd66997f2f
@ -329,6 +329,7 @@ Available formatters:
|
|||||||
Settings:
|
Settings:
|
||||||
|
|
||||||
:format: (default: ``♪: {volume}``)
|
:format: (default: ``♪: {volume}``)
|
||||||
|
:format_muted: optional format string to use when muted (default: ``None``)
|
||||||
:mixer: ALSA mixer (default: ``Master``)
|
:mixer: ALSA mixer (default: ``Master``)
|
||||||
:mixer_id: ALSA mixer id (default: ``0``)
|
:mixer_id: ALSA mixer id (default: ``0``)
|
||||||
:card: ALSA sound card (default: ``0``)
|
:card: ALSA sound card (default: ``0``)
|
||||||
@ -753,6 +754,7 @@ Available formatters:
|
|||||||
Settings:
|
Settings:
|
||||||
|
|
||||||
:format: (default: ``♪: {volume}``)
|
:format: (default: ``♪: {volume}``)
|
||||||
|
:format_muted: optional format string to use when muted (default: ``None``)
|
||||||
:muted: (default: ``M``)
|
:muted: (default: ``M``)
|
||||||
:unmuted: (default: ````)
|
:unmuted: (default: ````)
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class ALSA(IntervalModule):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
"format",
|
"format",
|
||||||
|
("format_muted", "optional format string to use when muted"),
|
||||||
("mixer", "ALSA mixer"),
|
("mixer", "ALSA mixer"),
|
||||||
("mixer_id", "ALSA mixer id"),
|
("mixer_id", "ALSA mixer id"),
|
||||||
("card", "ALSA sound card"),
|
("card", "ALSA sound card"),
|
||||||
@ -34,6 +35,7 @@ class ALSA(IntervalModule):
|
|||||||
color_muted = "#AAAAAA"
|
color_muted = "#AAAAAA"
|
||||||
color = "#FFFFFF"
|
color = "#FFFFFF"
|
||||||
format = "♪: {volume}"
|
format = "♪: {volume}"
|
||||||
|
format_muted = None
|
||||||
mixer = "Master"
|
mixer = "Master"
|
||||||
mixer_id = 0
|
mixer_id = 0
|
||||||
card = 0
|
card = 0
|
||||||
@ -68,7 +70,12 @@ class ALSA(IntervalModule):
|
|||||||
self.fdict["volume"] = self.alsamixer.getvolume()[self.channel]
|
self.fdict["volume"] = self.alsamixer.getvolume()[self.channel]
|
||||||
self.fdict["muted"] = self.muted if muted else self.unmuted
|
self.fdict["muted"] = self.muted if muted else self.unmuted
|
||||||
|
|
||||||
|
if muted and self.format_muted is not None:
|
||||||
|
output_format = self.format_muted
|
||||||
|
else:
|
||||||
|
output_format = self.format
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format.format(**self.fdict),
|
"full_text": output_format.format(**self.fdict),
|
||||||
"color": self.color_muted if muted else self.color,
|
"color": self.color_muted if muted else self.color,
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,14 @@ class PulseAudio(Module):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
"format",
|
"format",
|
||||||
|
("format_muted", "optional format string to use when muted"),
|
||||||
"muted", "unmuted"
|
"muted", "unmuted"
|
||||||
)
|
)
|
||||||
|
|
||||||
muted = "M"
|
muted = "M"
|
||||||
unmuted = ""
|
unmuted = ""
|
||||||
format = "♪: {volume}"
|
format = "♪: {volume}"
|
||||||
|
format_muted = None
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
"""Creates context, when context is ready context_notify_cb is called"""
|
"""Creates context, when context is ready context_notify_cb is called"""
|
||||||
@ -97,8 +99,13 @@ class PulseAudio(Module):
|
|||||||
|
|
||||||
muted = self.muted if sink_info.mute else self.unmuted
|
muted = self.muted if sink_info.mute else self.unmuted
|
||||||
|
|
||||||
|
if muted and self.format_muted is not None:
|
||||||
|
output_format = self.format_muted
|
||||||
|
else:
|
||||||
|
output_format = self.format
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format.format(
|
"full_text": output_format.format(
|
||||||
muted=muted,
|
muted=muted,
|
||||||
volume=volume_percent,
|
volume=volume_percent,
|
||||||
db=volume_db),
|
db=volume_db),
|
||||||
|
Loading…
Reference in New Issue
Block a user