Hi,
I'm getting an "Error in block 'sound': could not get sound info" after plugging in an external soundcard, which is assigned the card 0 slot by alsa. The output from aplay -l is:
**** List of PLAYBACK Hardware Devices ****
card 0: UCX23815246 [Fireface UCX (23815246)], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC257 Analog [ALC257 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0
The external sound card can't be controlled from amixer, which is probably the root cause of the problem. I haven't yet gone down the rabbit hole of aliasing my alsa devices to give them persistent indices (which I probably should), but then I saw the possibility of naming the sound card in the block. However, no combination of names for the device that I can think of works. Is there a special naming convention I haven't cracked here? The card I would like to use is PCH device 0.
OK, found it! Using the name from amixer does the trick:
[[ block]]
block = "sound"
name = "PCM,0"
Could this be specified in the docs? There are just so many ways to list device names in alsa, so it would be handy to know what i3status-rs looks for....
Send a PR. Or I can do it later.
Yup. Still seems like there's something a bit fishy going on, though, so I will continue investigating a bit to see what happens in different setups and names...
OK, so the plot thickens a bit. The name "PCM,0" was in fact the name of the external card, which makes the status bar return to normal, but doesn't help me when I return to the internal sound card from cadence. I still haven't found a way to name the internal card. amixer -D "hw:PCH" correctly lists the card's capabilities like this:
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 87
Mono: Playback 73 [84%] [-10.50dB] [on]
Simple mixer control 'Headphone',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 87
Mono:
Front Left: Playback 87 [100%] [0.00dB] [on]
Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Speaker',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 87
Mono:
Front Left: Playback 87 [100%] [0.00dB] [on]
Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Mic Boost',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 3
Front Left: 0 [0%] [0.00dB]
Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Mic Mute-LED Mode',0
Capabilities: enum
Items: 'On' 'Off' 'Follow Capture' 'Follow Mute'
Item0: 'Follow Mute'
Simple mixer control 'IEC958',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'IEC958',1
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'IEC958',2
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'IEC958',3
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'IEC958',4
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch
Capture channels: Front Left - Front Right
Limits: Capture 0 - 63
Front Left: Capture 39 [62%] [12.00dB] [on]
Front Right: Capture 39 [62%] [12.00dB] [on]
Simple mixer control 'Auto-Mute Mode',0
Capabilities: enum
Items: 'Disabled' 'Enabled'
Item0: 'Enabled'
Simple mixer control 'Internal Mic Boost',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 3
Front Left: 0 [0%] [0.00dB]
Front Right: 0 [0%] [0.00dB]
but putting any version of "PCH", "hw:PCH" into the name parameter of the config file triggers the error.
OK, so I found a workaround. No matter what kind of tricks I try to pull on the name of the soundcard, the sound module always seems to want to relate to soundcard number 0, i.e. the first card that is loaded on boot. To get around this you can set the card index manually, so that the indexing is persistent. In my case this is:
/etc/modprobe.d/alsa-base.conf
---
options snd_hda_intel index=0
options snd_usb_audio index=1
The card names can be found by running
$ cat /proc/asound/modules
For more info: archwiki to the rescue as per usual.
However, this still leaves the problem that I can't name the card, which is obviously not ideal.
I'm also having this issue even though amixer has a valid output.
amixer output:
Simple mixer control 'Headphone',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 3
Mono:
Front Left: Playback 3 [100%] [0.00dB]
Front Right: Playback 3 [100%] [0.00dB]
Simple mixer control 'Headphone Mixer',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 11
Front Left: 11 [100%] [0.00dB]
Front Right: 11 [100%] [0.00dB]
Simple mixer control 'Speaker',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'Mic Boost',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'Playback Polarity',0
Capabilities: enum
Items: 'Normal' 'R Invert' 'L Invert' 'L + R Invert'
Item0: 'R Invert'
Simple mixer control 'Capture Polarity',0
Capabilities: enum
Items: 'Normal' 'Invert'
Item0: 'Normal'
Simple mixer control 'ADC',0
Capabilities: cvolume cvolume-joined
Capture channels: Mono
Limits: Capture 0 - 192
Mono: Capture 192 [100%] [0.00dB]
I found a _"workaround"_ which is to use pulse audio as the backend since it has stable/predictable interface names.
@AndreVallestero When you were using the ALSA backend, it didn't work with any of those device names from the output above (Headphone, Headphone Mixer, Speaker, etc)? All the code does is call amixer -M get devicename so it seems strange for it not to work, unless you specified a device that doesn't exist or doesn't have volume info in the output.
Hi guys, I'm still a bit in the dark here. I've avoided the problem by not having pulseaudio installed, but lately I've had to use it. My setup is alsa->PulseAudio->Jack, using the Cadence PulseAudio bridge, which ensures that as long as pulseaudio is running it will show up as:
pcm.!default {
type plug
slave { pcm "pulse" }
}
pcm.pulse {
type pulse
}
ctl.mixer0 {
type hw
card 0
}
So pulseaudio is the default output, but the _actual_ output is coming from jack-alsa, and this is the one I would like to show up in the sound module. Tried setting the driver parameter to "alsa", but this doesn't change anything. So basically the problem boils right back down to the naming of the output, which I don't see how to to while pulseaudio is running. If I kill it and restart sway, the alsa output becomes available again for the sound module...
As mentioned above, the ALSA backend simply parses the output of amixer -M get devicename, so if your device doesn't show in the output of amixer then it's not possible to get the info using the alsa driver.
OK, I'm beginning to get a handle on this. Sorry for being a bit dense earlier... The problem with amixer -M get devicename is that devicename is not, in fact, the device name, but rather the name of the control. In my case, with pulseaudio started, amixer -M get hw:PCH (which is the name I am interested in) will return
amixer: Unable to find simple control 'hw:PCH',0
Whereas amixer -M get Master will get me the pulseaudio controls (which I am not interested in). Furthermore, if I run amixer -M get PulseAudio I will get another
amixer: Unable to find simple control 'PulseAudio',0
Now, if I run amixer -M -D hw:PCH get Master instead I _do_ get access to the correct controls, so it seems to me this would be a better way to retrieve the name configuration parameter for the correct device. All devices that are controllable by amixer would probably have a Master control somewhere.
Interesting, could you share the output of amixer and aplay -l as well?
This is what mine looks like
>amixer
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 5208 [8%] [on]
Front Right: Playback 5208 [8%] [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]
>aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: ALC887-VD Digital [ALC887-VD Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 11: HDMI 5 [HDMI 5]
Subdevices: 1/1
Subdevice #0: subdevice #0
amixer
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 65536 [100%] [on]
Front Right: Playback 65536 [100%] [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 61680 [94%] [on]
Front Right: Capture 61680 [94%] [on]
and
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC257 Analog [ALC257 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0
And I guess I should have been a bit more clear on the terminology: I am interested in the _card_ name, not necessarily the _device_ name.
EDIT: Sorry, messing up again... card and device together, not only card...
Furthermore:
> amixer -D hw:PCH get Master
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 87
Mono: Playback 50 [57%] [-27.75dB] [on]
Ah, sorry I missed that you already posted the output above!
It seems like if we add a config param to specify the -D option value for amixer then it should solve your problem, right? Then just need to document it properly.
I guess it would solve it, yes! I鈥檇 be happy to test it if you do.
I think we should probably follow this model:
https://github.com/vivien/i3blocks-contrib/blob/master/volume/volume
That looks very good and comprehensive!
@kflak Could you please try #622? It should hopefully solve your issue.
Thanks a lot! On my system this works with these settings:
[[block]]
block = "sound"
driver = "alsa"
device = "hw:PCH"
name = "Master"
It _also_ works with
device = "hw:0"
Most helpful comment
OK, so I found a workaround. No matter what kind of tricks I try to pull on the name of the soundcard, the sound module always seems to want to relate to soundcard number 0, i.e. the first card that is loaded on boot. To get around this you can set the card index manually, so that the indexing is persistent. In my case this is:
The card names can be found by running
For more info: archwiki to the rescue as per usual.
However, this still leaves the problem that I can't name the card, which is obviously not ideal.