dwm-status icon indicating copy to clipboard operation
dwm-status copied to clipboard

Audio feature wrong volume

Open h0useofdupree opened this issue 3 years ago • 8 comments

This is totally not your fault, it is more a question on my side. The Control "Master" doesn't show my actual volume. And none of "amixer get <PCM/Speaker/etc> outputs show my actual volume. Is there anyway you could help me? I've spent hours trying to figure it out with the original dwmstatus and wanted to try yours now. Best regards, Joel

h0useofdupree avatar May 07 '21 13:05 h0useofdupree

Hey, yeah I have some issues with amixer too sometimes. Until today, I only did trial and error. Are you using pulseaudio? Maybe have a look into pavucontrol and set the default output device.

Gerschtli avatar May 07 '21 13:05 Gerschtli

Yes I am already using pulseaudio. Sadly that means that I can't get around trying to rewrite the audio part of your code, so it would fit the output i used for the original dwmstatus, although I don't think i am qualified to do so. I will report back tomorrow and see if I was able to do something. Thanks for the reply.

h0useofdupree avatar May 07 '21 22:05 h0useofdupree

I fixed some stuff today by disabling my intel SoundCard, now my USB Interface is set a default basically. Tho my volume needs to be controlled by Pulse anyway, so do you have any idea or tips for me, so i can alter your audio feature to display the output of pactl or pacmd ? I'd love to see my volume in the bar and i really wanna keep yours.

Sincerely, Joel

h0useofdupree avatar May 08 '21 21:05 h0useofdupree

A new option for the audio feature could be added, but I need to know how to get the current volume and a trigger to update the bar when volume changes.

Feel free to have a look at src/feature/audio.

Gerschtli avatar May 08 '21 21:05 Gerschtli

I really am no expert but i am able to get the volume with "pulsemixer --get-volume" and cut it down to one number with "pulsemixer --get-volume | cut -c 1-2" My volume is controlled via DWM config.h command "pactl set-sink-volume <sink (1)> <value(+5%/-5%)>" ( pulsmixer can't increment volume afaik ). I could simply get the bar to update when my volume keys are pressed, or much easier, it would be enough to have a timer update it like once a second.

I am just not able to implement the reading of the current volume ( yet, hopefully )

h0useofdupree avatar May 08 '21 22:05 h0useofdupree

I would propose the following:

  • Introduce a new option audio.backend which is per default alsa and can be set to pulseaudio
  • When backend set to pulseaudio:
    • In src/features/audio/notifier.rs run pactl subscribe to get updates when the volume changes or muting
    • In src/features/audio/updater.rs fetch current volume with pulsemixer --get-volume and mute state with pulsemixer --get-mute

Would these commands work in your environment? If you know rust, you can try to create a PR. Don't know when I have the time for it.

Gerschtli avatar May 09 '21 14:05 Gerschtli

I just put something together at pulseaudio branch. The only thing missing is a nice and easy way to trigger updates for the audio component. pactl subscribe only logs connections which are also created when reading the volume. This results currently in an infinite loop. I would love to get a kind of push logic implemented, this way the component updates only when needed and is always up-to-date. Unfortunately I did not find any solution for this. A time-based solution would work if thats the only way.

Do you have any ideas? Does alsactl monitor print anything when you change volume or switch mute on and off?

Gerschtli avatar May 09 '21 15:05 Gerschtli

Hey sorry for only answering now. I just checked it out and i love it. It works perfectly. I couldn't get alsactl to show volume changes, but i am working on something that might enable me to get volume changes. Thank you so much for doing this! The infinite loop makes sense, pact subscribe isn't as useful as I had hoped.

h0useofdupree avatar May 12 '21 07:05 h0useofdupree