volume_status module should do a better job figuring out default channel to use
jose1711 opened this issue · comments
Is your feature request related to a problem? Please describe.
If you install and configure py3status
on Raspberry Pi (tested w/ RPi 3) with volume_status
module activated and go with defaults, the module will return error because no Master
channel exists on this platform. PCM
must be used instead.
Your py3status version
py3status version 3.44 (python 3.10.4) on i3
Describe the solution you'd like
It would be preferred if py3status
figures out the channel in a more intelligent way - e. g. by parsing amixer
output (amixer scontrols
seems to be providing useful output) or looking at /proc/asound
...
Describe alternatives you've considered
Manual configuration or building a config from a (e. g. jinja2) template.
Additional context
n/a
Edit: add potentially useful amixer
command.
Grab the first control (Master
, PCM
, etc)... Otherwise, grab the last control... hopefully Capture
.
EDIT: Diff updated to use splitlines()
instead.
EDIT: Diff updated to omit unnecessary int()
.
diff --git a/py3status/modules/volume_status.py b/py3status/modules/volume_status.py
index acf9b5e..60d41ac 100644
--- a/py3status/modules/volume_status.py
+++ b/py3status/modules/volume_status.py
@@ -114,7 +114,8 @@ class Amixer(Audio):
if self.card is None:
self.card = "0"
if self.channel is None:
- self.channel = "Capture" if self.is_input else "Master"
+ controls = self.parent.py3.command_output(["amixer", "scontrols"]).splitlines()
+ self.channel = controls[-abs(self.is_input)].split("'")[1::2][0]
if self.device is None:
self.device = "default"
self.cmd = [
Thank you, that seems to be working. Will there be a PR?