You are not logged in.

#1 2019-03-18 10:18:33

Shinwoir
Member
Registered: 2018-01-20
Posts: 40

[SOLVED] Volume gets unbalanced when using volume wheel

I have a volume wheel on my keyboard which I mapped to volume controls by putting this in my i3 config

#Volume controls
bindsym XF86AudioRaiseVolume exec amixer -q set Master 5%+ unmute
bindsym XF86AudioLowerVolume exec amixer -q set Master 5%- unmute
bindsym XF86AudioMute exec amixer -q set Master toggle

Here's what it does: https://streamable.com/eh3oc
It doesn't happen with the volume keys on my laptop, only with the wheel

Last edited by Shinwoir (2019-03-18 14:16:04)

Offline

#2 2019-03-18 10:44:06

frostschutz
Member
Registered: 2013-11-15
Posts: 1,637

Re: [SOLVED] Volume gets unbalanced when using volume wheel

can you reproduce the same issue by running these commands on the shell directly? then it's a problem with amixer. (I don't have amixer installed actually... so I can't try.)

otherwise, it could be a race condition, like if that wheel is trigger happy (or the command is just slow), multiple amixer could run in parallel, causing side effects if amixer has no race prevention builtin.

in that case you could use flock to avoid race

bindsym XF86AudioRaiseVolume exec flock -n /tmp/amixer-flock amixer -q set Master 5%+ unmute
bindsym XF86AudioLowerVolume exec flock -n /tmp/amixer-flock amixer -q set Master 5%- unmute
bindsym XF86AudioMute exec flock -n /tmp/amixer-flock amixer -q set Master toggle

-n is optional, means ignore command if another is still running, so -n might miss key events

not using -n would introduce delay in processing key events

if you prefer delay you could replace -n with something like -w 0.5 to allow at most half second delays

Last edited by frostschutz (2019-03-18 10:48:53)

Offline

#3 2019-03-18 13:52:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: [SOLVED] Volume gets unbalanced when using volume wheel

You really also shouldn't change pulseaudio volumes by shoehorning over the compatibility mixer.

Use pulseaudio tools to change your volume:

#Volume controls
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle

Synchronisation of the ALSA volume over to your pulseaudio volume with the ALSA->pulse compat device isn't guaranteed, and there can be all sorts of weird behavior.

Offline

#4 2019-03-18 14:15:54

Shinwoir
Member
Registered: 2018-01-20
Posts: 40

Re: [SOLVED] Volume gets unbalanced when using volume wheel

V1del wrote:

You really also shouldn't change pulseaudio volumes by shoehorning over the compatibility mixer.

Use pulseaudio tools to change your volume:

#Volume controls
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle

Synchronisation of the ALSA volume over to your pulseaudio volume with the ALSA->pulse compat device isn't guaranteed, and there can be all sorts of weird behavior.

I see, I didn't know about all the sinks stuff, and using amixer seemed easier to me. Thanks a lot for the help

Offline

Board footer

Powered by FluxBB