enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 188 forks source link

alsa: set card with default -1 instead of hardcoded 0 #725

Closed lasers closed 5 years ago

lasers commented 5 years ago

I think https://github.com/enkore/i3pystatus/issues/307 may have been caused by hardcoded 0 instead of default -1 according to https://larsimmisch.github.io/pyalsaaudio/libalsaaudio.html#mixer-objects.

class alsaaudio.Mixer(control='Master', id=0, cardindex=-1, device='default')`

... which might explain this exception...

The exception is quite specific:

alsaaudio.ALSAAudioError: Unable to find mixer control Master,0 [hw:0]

And reveals that the settings are correctly passed to pyalsaaudio. Could it be a permission problem? Or maybe some application (DAW?) you are running opens this ALSA card exclusively?

Maybe it can't work with 0 and wanted 1... or 0 is something else such as mics?

Also, when I compare card settings, I find -1 card printing volume percentage more accurate.

status.register(
    "alsa",
    format="♪: {volume} {card}",
    card=0,
)
status.register(
    "alsa",
    format="♪: {volume} {card}",
    card=-1,
)

I'd like to use this PR to close https://github.com/enkore/i3pystatus/issues/307. OP no longer uses i3pystatus too.

lasers commented 5 years ago

Bump. Easy fix imho.

enkore commented 5 years ago

Thanks!