What's the reason of mixer(8) CLI redesign?

mixer: remove volume backwards compat, add % interpretation

The current situation is fairly confusing, where an integer is interpreted
as a percent until you slap a decimal on it and magically it becomes an
absolute value.

Let's have a flag day in 14.0 and remove this shim entirely. Setting with
percent can still be useful, so allow a trailing '%' to indicate as such.
As a side effect, we tighten down the format allowed in the volume a little
bit by ensuring there's no trailing garbage after the value once it's
separated into left and right components.
 
Agreed, for what it's worth. Now I use mixertui, which is quite similar to the Linux alsamixer, and can work without a GUI. Formerly, one could just use mixer vol=90:90 (if I remember the syntax correctly), and you were done.
 
Typing an additional . or % doesn't kill it for me, but the move was somewhat arbitrary, agreed. I wasn't involved back then. There will be more changes coming in CURRENT, mostly about internals and parsing robustness though. I'm not sure the old implementation will still be compatible, we weren't even aware of audio/freebsd-13-mixer.
 
I would like to ask why value was changed to a decimal number instead of an integer. In my personal opinion, the new approach in 14.0 mixer is less comfortable to read and write. For example, 80 is more readable and writable than 0.8.
Not just more readable: in a pure shell script there are no operations with float, whereas an integer can be easily e.g. incremented with $((VOL+1)).
 
I dont like new mixer too.
a very strange and unintuitive tool. a solution that makes no sense. the old solution was great. I don't know why you grind up something that worked well but is used incorrectly. the new mixer is hopeless.
 
To be honest, I didn't even figure out the new mixer until after I'd given up and installed mixertui. I don't remember what I tried typing, but I was getting results of invalid command, invalid device, etc. I was probably trying mixer vol=1, mixer -f /dev/pcm, or something, but I really don't remember. Now I would say that I've figured it out, and probably could have had I read the man page a bit more carefully, but at the time, it was frustrating as the old mixer was not only pretty simple, but had a nice wiki or handbook page with examples.
 
The same here..I hate the change , I had to adapt te volume-up/down script in my DE (ctrl+minus/plus keys)
maybe this help you,(needs xosd and had limitators when the volume is >X exit and when volume down is X< exit):

volume up
Code:
#!/usr/local/bin/bash
val=`mixer vol.volume |awk '{split($1,a,"="); print a[2]}'|awk '{split($0,a,":"); print a[1]}'`

valor=`echo $val | awk '{split($0,a,"."); print a[2] }'`
primer_valor=`echo $val | awk '{split($0,a,"."); print a[1] }'`

if [ "$primer_valor" -eq "0" ]; then

if [ $valor -gt 89 ]; then
echo "afuera"
exit
fi


val_final=$((valor+5))
val_ultimo="0."$val_final

mixer vol.volume=$val_ultimo
killall osd_cat 2> /dev/null

osd_cmd='osd_cat --font=-*-fixed-bold-r-*-*-18-*-*-*-*-*-*-* --shadow=1 --color=#1E90FF \
--pos=bottom --offset=30 --align=center --lines=2 --delay=1 --barmode=percentage \
--percentage='$val_final' --text='Master-Volume:$val_ultimo' )'

osd_cat $osd_cmd

ps_out=`pidof osd_cat`

fi


volume down
Code:
val=`mixer vol.volume |awk '{split($1,a,"="); print a[2]}'|awk '{split($0,a,":"); print a[1]}'`
valor=`echo $val | awk '{split($0,a,"."); print a[2] }'`
primer_valor=`echo $val | awk '{split($0,a,"."); print a[1] }'`

if [ "$primer_valor" -eq "0" ]; then
 
if [ $valor -lt 15 ]; then
exit
fi

val_final=$((valor-5))
val_ultimo="0."$val_final
mixer vol.volume=$val_ultimo
ps_out=`pidof osd_cat`

 
ps_out=`pidof osd_cat`

killall osd_cat 2> /dev/null


osd_cmd='osd_cat --font=-*-fixed-bold-r-*-*-18-*-*-*-*-*-*-* --shadow=1 --color=#1E90FF \
--pos=bottom --offset=30 --align=center --lines=2 --delay=1 --barmode=percentage \
--percentage='$val_final' --text='Master-Volume:$val_ultimo' )'

osd_cat $osd_cmd

ps_out=`pidof osd_cat`

if [ $ps_out > 1 ]
then
killall osd_cat 2> /dev/null
fi

fi
 
Did the reports help?
 

Attachments

  • 1721431416662.png
    1721431416662.png
    10.8 KB · Views: 39
Not just more readable: in a pure shell script there are no operations with float, whereas an integer can be easily e.g. incremented with $((VOL+1)).

Well you can set volume as a percentage (e.g. mixer vol.volume=75%), and there's builtin syntax to increase / decrease the values. The only thing I see missing is a way to read out current values as a percentage. I suppose we could add that as a new feature (no promise). Anything else?

Apart from the decimal point value representation, I think it's pretty obvious why the old code had to go. And to let users set the default pcm device is a nice addition. But I do value a good rant like everybody else here ;-)
 
There is an -o option for command line parsing, for instance I read it as percentage like this:
mixer -o vol.volume | awk -F = '{print $2}' | awk -F : '{printf "L %d %d R", 100*$1, 100*$2}'
And to show my device:
mixer | awk 'match($0,"<") {print substr($0,RSTART+RLENGTH)}' | awk 'match($0,">") {print substr($0,0,RSTART-RLENGTH)}'

What is really missing is libxo support.
 
There is an -o option for command line parsing, for instance I read it as percentage like this:
mixer -o vol.volume | awk -F = '{print $2}' | awk -F : '{printf "L %d %d R", 100*$1, 100*$2}'
And to show my device:
mixer | awk 'match($0,"<") {print substr($0,RSTART+RLENGTH)}' | awk 'match($0,">") {print substr($0,0,RSTART-RLENGTH)}'

Still a bit complicated just to read out the current volume.

What is really missing is libxo support.

Good idea, could you name a specific use case for that?
For full-fledged mixer applications there's the mixer(3) library. Are there any tools in base to read and extract values from libxo output formats? Means it could be used for simple scripts like that of wolffnx ?
 
I think it's pretty obvious why the old code had to go. And to let users set the default pcm device is a nice addition.
OK, the code had to go, but I'm worrying about the interface.
Agreed, setting the default pcm device is a good addition, however, it's never been a problem:
sysctl hw.snd.default_unit=N
has been always working for regular users.
 
I don't use the utility, but this seems simple enough:

Code:
% mixer -a | grep -B 1 vol
pcm0:mixer: <NVIDIA (0x0042) (HDMI/DP 8ch)> on hdaa0 (play)
    vol       = 1.00:1.00     pbk
--
pcm1:mixer: <NVIDIA (0x0042) (HDMI/DP 8ch)> on hdaa0 (play)
    vol       = 1.00:1.00     pbk
--
pcm2:mixer: <NVIDIA (0x0042) (HDMI/DP 8ch)> on hdaa0 (play)
    vol       = 1.00:1.00     pbk
--
pcm3:mixer: <Realtek ALC280 (Analog 2.0+HP/2.0)> on hdaa1 (play/rec) (default)
    vol       = 1.00:1.00     pbk
%
 
Back
Top