Page 1 of 1

Why is there values mismatch between amixer and alsamixer?

Posted: Sat Oct 10, 2015 11:17 am
by Nachei
I'd like to set a keyboard-driven volume control (+ key for volume up, - for volume down) that is coherent with the volume levels used by alsamixer. My Internet research shows that the command to use for that would be amixer sset. However, if I open alsamixer, and in a different terminal I send amixer sset commands, the numbers don't match! Examples:

amixer sset Master 80 ----> In AlsaMixer Master reaches 100
amixer sset Master 50 ----> In AlsaMixer Master reaches 36

I've tried using PCM instead of Master and the mismatch happens the same. The AlsaMixer version is 1.0.26, fwiw. Could someone explain this to me or provide a clarifying link? Thank you.

Re: Why is there values mismatch between amixer and alsamixe

Posted: Sat Oct 10, 2015 2:19 pm
by Luc
I don't know why, but why should this matter so much? Just raise or lower the volume, that's all you need. And it helps to know that the maximum volume in amixer is 64.

~/.config/openbox/lxde-rc.xml

Code: Select all

    <!-- Keybinding for Volume management -->
    <keybind key="XF86AudioRaiseVolume">
      <action name="Execute">
        <command>~/xxxx/volumechange.fish up</command>
      </action>
    </keybind>
    <keybind key="XF86AudioLowerVolume">
      <action name="Execute">
        <command>~/xxxx/volumechange.fish down</command>
      </action>
    </keybind>
    <keybind key="XF86AudioMute">
      <action name="Execute">
        <command>amixer -q sset Master toggle</command>
      </action>
    </keybind>
~/.config/fish/functions/volumechange.fish

Code: Select all

#!/usr/bin/env fish
function volumechange
	set _choice $argv[1]
	
	if	test $_choice = "up"
		amixer -q sset Master unmute
		amixer -q sset Master 2+
		set _currVolume (amixer sget Master | sed -r '/%/!d;s/.*\[([0-9]+)%.*/\1/')
		echo $_currVolume
		osdctl -b "vol $_currVolume",$_currVolume
	end
	if	test $_choice = "down"
		amixer -q sset Master unmute
		amixer -q sset Master 2-
		set _currVolume (amixer sget Master | sed -r '/%/!d;s/.*\[([0-9]+)%.*/\1/')
		osdctl -b "vol $_currVolume",$_currVolume
	end
	if	test $_choice = "max"
		amixer -q sset Master unmute
		amixer -q sset Master 64
		set _currVolume (amixer sget Master | sed -r '/%/!d;s/.*\[([0-9]+)%.*/\1/')
		osdctl -b "vol $_currVolume",$_currVolume
	end
	if	test $_choice = "mute"
		amixer -q sset Master mute
		osdctl -b MUTE,0
	end
end
You may want to install osdsh for the full package.