How can I limit max volume for a sound card?

Hello! I’m currently running EndeavourOS with Plasma and pipewire as my audio server. Unfortunately, my specific laptop (HP Chromebook x360 14" (SONA) with coreboot and endeavour OS only) has a known issue where you can overdrive and blow out your speakers. As such, it is on me to ensure that I limit volume to avoid damaging my laptop.

Ideally, I’d love to set up a limit so that within plasma-pa or with my keyboard keys, I cannot raise the volume past 20% or so when using that sink. (or allowing 0-100% in plasma-pa and limiting it further in the chain). Unfortunately, I am struggling to find a solution to this problem.

I originally thought that maybe it could be limited within plasma. It seems that plasma-pa used to have a set volume limit function, but in 2020 it was replaced with a toggle to enable boosted volume (100-150%), thus removing the ability to limit the volume to less than 100%.

The question is, where is the best place for me to try and limit the volume output? Is this something I should be looking into within pipewire? Or since I only want to limit the built-in speakers, does that mean I should be looking into limiting volume output at the alsa level?

Any pointers would be much appreciated, as I’m relatively inexperienced with linux audio.

Thanks!

Try alsamixer, press f6 choose card and lower the volume. I had to do the opposite (sound too low) recently.

1 Like

An emergency workaround. It’s not elegant I admit.
yay -S pulsemixer
Put into autostart this script:

#!/bin/bash
systemctl --user stop pipewire.socket
sleep 2
systemctl --user stop pipewire.service
sleep 1
systemctl --user start pulseaudio.service
systemctl --user start pulseaudio.socket

and schedule a command periodically
pulsemixer --change-volume +5 --max-volume 50

Thanks for the suggestion, but even when I select the specific sound card to lower the volume there, it stays linked to plasma-pa. In other words, I could try to limit my sound card’s output t0 50% in alsamixer but then I can just scroll over the volume applet and turn it right back up to 100%.