pulseaudio: add muted/unmuted options
This commit is contained in:
parent
c4c03faea1
commit
751f0bbb14
@ -12,12 +12,16 @@ class PulseAudio(Module):
|
||||
* `{volume}` — volume in percent (0...100)
|
||||
* `{db}` — volume in decibels relative to 100 %, i.e. 100 % = 0 dB, 50 % = -18 dB, 0 % = -infinity dB
|
||||
(the literal value for -infinity is `-∞`)
|
||||
* `{muted}` — the value of one of the `muted` or `unmuted` settings
|
||||
"""
|
||||
|
||||
settings = (
|
||||
"format",
|
||||
"muted", "unmuted"
|
||||
)
|
||||
|
||||
muted = "M"
|
||||
unmuted = ""
|
||||
format = "♪: {volume}"
|
||||
|
||||
def init(self):
|
||||
@ -85,13 +89,19 @@ class PulseAudio(Module):
|
||||
sink_info = sink_info_p.contents
|
||||
volume_percent = int(100 * sink_info.volume.values[0] / 0x10000)
|
||||
volume_db = pa_sw_volume_to_dB(sink_info.volume.values[0])
|
||||
|
||||
if volume_db == float('-Infinity'):
|
||||
volume_db = "-∞"
|
||||
else:
|
||||
volume_db = int(volume_db)
|
||||
|
||||
muted = self.muted if sink_info.mute else self.unmuted
|
||||
|
||||
self.output = {
|
||||
"full_text": self.format.format(volume=volume_percent, db=volume_db),
|
||||
"full_text": self.format.format(
|
||||
muted=muted,
|
||||
volume=volume_percent,
|
||||
db=volume_db),
|
||||
}
|
||||
|
||||
def on_leftclick(self):
|
||||
|
Loading…
Reference in New Issue
Block a user