Compare commits

...

2 Commits

Author SHA1 Message Date
6d502ea67e fix source sliders 2023-12-23 16:10:20 +01:00
165879eb0d fix color buttons 2023-12-23 15:18:14 +01:00
2 changed files with 25 additions and 5 deletions

View File

@@ -199,12 +199,18 @@ class Button(QBtn):
self.command = '' # command to run on click
self.state = '' # output of the state check command
self.state_command = '' # command to check the unclicked state
self.color_bg = kwargs.pop('color_bg', '')
self.color_fg = kwargs.pop('color_fg', '')
super().__init__(**kwargs)
self.style = "width: 90px;"
self.style += "min-height: 77px;" # image + 2 text lines
self.style += "border: 1px solid var(--c-blue-grey-8);" # #455a64 blue-grey-8
self.style += "line-height: 1em;"
if self.color_bg:
self.style += f"background-color: {self.color_bg};"
if self.color_fg:
self.style += f"color: {self.color_fg} !important;"
# if DEBUG:
# print(f'[DEBUG] button: {self.text}; image: {self.image}; exists: {path.exists(self.image)}')
@@ -348,7 +354,7 @@ class Volume(Div):
if self.wtype == 'sink':
cmdl_toggle = 'pactl set-sink-mute {name} toggle'
cmdl_value = 'pactl set-sink-volume {name} {value}%'
if self.wtype == 'source':
elif self.wtype == 'source':
cmdl_toggle = 'pactl set-source-mute {name} toggle'
cmdl_value = 'pactl set-source-volume {name} {value}%'
self.icon_muted = 'mic_none' # default icon for muted state, 'mic_off' better for disabled?
@@ -460,13 +466,23 @@ class Volume(Div):
print("'pactl -f json list sinks' returns: '", sinks, "'")
# fill (initialize) key 'sinks' and 'sink-inputs' to empty list so not enter KeyError
cls.data['sinks'] = []
cls.data['sources'] = []
cls.data['sink-inputs'] = []
else:
cls.data['sinks'] = json.loads(sinks)
# only do additionals if sink was working
sources = process('pactl -f json list sources', shell=True, stderr=None)
if 'failure' in sources:
print("'pactl -f json list sources' returns: '", sources, "'")
cls.data['sources'] = []
else:
cls.data['sources'] = json.loads(sources)
sink_inputs = process('pactl -f json list sink-inputs', shell=True, stderr=None) # stderr might have e.g.: Invalid non-ASCII character: 0xffffffc3
if 'failure' in sinks:
print("'pactl -f json list sink-inputs' returns", sink_inputs)
if 'failure' in sink_inputs:
print("'pactl -f json list sink-inputs' returns: '", sink_inputs, "'")
cls.data['sink-inputs'] = []
else:
cls.data['sink-inputs'] = json.loads(sink_inputs)
@@ -480,6 +496,10 @@ class Volume(Div):
# match pa name with self.name
tmp = list(filter(lambda item: item['name'] == self.name,
Volume.data['sinks']))
elif self.wtype == 'source':
# match pa name with self.name
tmp = list(filter(lambda item: item['name'] == self.name,
Volume.data['sources']))
elif self.wtype == 'sink-input':
# match pa index with self.name
try: # for int casting

View File

@@ -35,8 +35,8 @@
# : N. optional group/row specification
# : NAME id, name of the button
# text-alt = optional alternative burron text
# color-fg = foreground color as hex color code, e.g. \#ff0000
# color-bg = background color as hex color code, e.g. \#ff0000
# color-fg = foreground color as hex color code, e.g. #aa5500
# color-bg = background color as hex color code, e.g. #0055aa
# command = command(s) to run, seperated by new lines: shell command
# second command ...
# command-alt = optinal back-switch command(s) to run: shell command ...