diff --git a/actions/Dial.py b/actions/Dial.py index 8479c30..4207f31 100644 --- a/actions/Dial.py +++ b/actions/Dial.py @@ -8,6 +8,7 @@ import globals as gl from loguru import logger as log from fuzzywuzzy import fuzz +import math import os @@ -27,12 +28,13 @@ def on_tick(self): inputs = self.plugin_base.pulse.sink_input_list() if index < len(inputs): - self.set_label(text=inputs[index].name, position="center", font_size=16) + self.update_labels() else: self.clear() def clear(self): self.set_media(image=None) + self.set_top_label(None) self.set_center_label(None) def event_callback(self, event, data): @@ -59,8 +61,27 @@ def event_callback(self, event, data): self.plugin_base.pulse.volume_set_all_chans(obj=inputs[index], vol=max(0, volume)) + self.update_labels() + def get_index(self) -> int: start_index = self.plugin_base.start_index own_index = int(self.input_ident.json_identifier) index = start_index + own_index - return index \ No newline at end of file + return index + + def update_labels(self): + inputs = self.plugin_base.pulse.sink_input_list() + index = self.get_index() + + if inputs[index].mute == 0: + # Display volume % if input is not muted + volumeLabel = str(math.ceil(inputs[index].volume.value_flat*100)) + "%" + labelColor = [255, 255, 255] + else: + # Display "muted" text if input is muted + volumeLabel = "- " + self.plugin_base.lm.get("input.muted").upper() + " -" + labelColor = [255, 0, 0] + + self.set_top_label(text=volumeLabel, color=labelColor, font_size=16) + self.set_center_label(text=inputs[index].name, font_size=18) + diff --git a/locales/de_DE.json b/locales/de_DE.json index 5ed0da9..18f00bc 100644 --- a/locales/de_DE.json +++ b/locales/de_DE.json @@ -20,5 +20,6 @@ "actions.move-left.name": "Nach links bewegen", "plugin.name": "Lautstärkemixer", "actions.hotkey.recorder.confirm-text": "Bestätigen", - "actions.hotkey.recorder.clear-text": "Zurücksetzen" -} \ No newline at end of file + "actions.hotkey.recorder.clear-text": "Zurücksetzen", + "input.muted": "Stumm" +} diff --git a/locales/en_US.json b/locales/en_US.json index 9c896e2..51a05aa 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -20,5 +20,6 @@ "actions.move-left.name": "Move Left", "plugin.name": "Volume Mixer", "actions.hotkey.recorder.confirm-text": "Confirm", - "actions.hotkey.recorder.clear-text": "Clear" -} \ No newline at end of file + "actions.hotkey.recorder.clear-text": "Clear", + "input.muted": "Muted" +} diff --git a/main.py b/main.py index ad4fdee..ce765da 100644 --- a/main.py +++ b/main.py @@ -172,5 +172,5 @@ def init_vars(self): self.original_page_path = None self.start_index = 0 self.pulse = pulsectl.Pulse("stream-controller", threading_lock=True) - self.volume_increment = 0.1 - self.volume_actions: list[ActionBase] = [] \ No newline at end of file + self.volume_increment = 0.05 + self.volume_actions: list[ActionBase] = []