[alsa-devel] vi-like key bindings for alsamixer
Hello List, I realized that 'j' and 'k' are not used nor reserved for future use with alsamixer. So I decided to use them as aliases for 'up' and 'down'. Is this deemed suitable for the masses?
Cheers, Simon Hengel
* Added 'j' as an alias for KEY_DOWN * Added 'k' as an alias for KEY_UP
Signed-off-by: Simon Hengel simon.hengel@gmx.net
diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index 414033e..c65c22d 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -2113,11 +2113,13 @@ mixer_iteration (void) mixer_hscroll_delta -= 1; break; case KEY_UP: + case 'k': case 'w': case 'W': mixer_vscroll_delta -= 1; break; case KEY_DOWN: + case 'j': case 'x': case 'X': mixer_vscroll_delta += 1; @@ -2179,12 +2181,14 @@ mixer_iteration (void) break; case 'w': case KEY_UP: + case 'k': mixer_set_delta(1); case 'W': mixer_add_delta(1); break; case 'x': case KEY_DOWN: + case 'j': mixer_set_delta(-1); case 'X': mixer_add_delta(-1);
Simon Hengel wrote:
I realized that 'j' and 'k' are not used nor reserved for future use with alsamixer. So I decided to use them as aliases for 'up' and 'down'.
But 'h' and 'l' are already used for other purposes, so these keys cannot be used to give a consistent vi-like behaviour.
Is this deemed suitable for the masses?
_Undocumented_ commands certainly aren't. ;-)
Best regards, Clemens
On Thu, Apr 02, 2009 at 08:56:21AM +0200, Clemens Ladisch wrote:
Is this deemed suitable for the masses?
_Undocumented_ commands certainly aren't. ;-)
This is certainly true.
While working on documentation I realized that '+' and KEY_UP, contrary to what is documented, do different things.
'+' increases volume by 1% whereas KEY_UP increases volume by 2%.
So actually it is like:
W | + increase volume by 1% w | KEY_UP increase volume by 2% X | - decrease volume by 1% x | KEY_DOWN decrease volume by 2%
Still this makes no difference with my hardware, as the granularity is > 3% (e.g. snd_mixer_selem_get_playback_volume_range gives {0, 31} or {0, 15} for {min, max}).
I wonder if it would be a good idea to unify it. Consequently one could do the same for left & right levels.
Contrary to what is documented '+' and KEY_UP did not the same thing. The behavior was as follows:
W | + increase volume by 1% w | KEY_UP increase volume by 2% X | - decrease volume by 1% x | KEY_DOWN decrease volume by 2%
Now all of them change the volume by only 1%.
Signed-off-by: Simon Hengel simon.hengel@gmx.net
diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index 414033e..554326f 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -1916,15 +1916,6 @@ mixer_set_delta(int delta) mixer_volume_delta[grp] = delta; }
-static void -mixer_add_delta(int delta) -{ - int grp; - - for (grp = 0; grp < 2; grp++) - mixer_volume_delta[grp] += delta; -} - static int mixer_iteration (void) { @@ -2172,22 +2163,16 @@ mixer_iteration (void) mixer_set_delta(-100); break; case '+': - mixer_set_delta(1); - break; - case '-': - mixer_set_delta(-1); - break; case 'w': + case 'W': case KEY_UP: mixer_set_delta(1); - case 'W': - mixer_add_delta(1); break; + case '-': case 'x': + case 'X': case KEY_DOWN: mixer_set_delta(-1); - case 'X': - mixer_add_delta(-1); break; case '0': case '1':
Contrary to what is documented 'q', 'e', 'z' and 'c' did different things as there upper case counterparts. The lower case versions changed volume by 2%, whereas the upper case commands changed volume by 1%.
Now all of them change the volume by only 1%.
Signed-off-by: Simon Hengel simon.hengel@gmx.net
diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index 554326f..51cd97e 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -2187,26 +2187,22 @@ mixer_iteration (void) mixer_volume_absolute = 10 * (key - '0'); break; case 'q': - mixer_volume_delta[MIXER_CHN_LEFT] = 1; case 'Q': - mixer_volume_delta[MIXER_CHN_LEFT] += 1; + mixer_volume_delta[MIXER_CHN_LEFT] = 1; break; case 'y': case 'z': - mixer_volume_delta[MIXER_CHN_LEFT] = -1; case 'Y': case 'Z': - mixer_volume_delta[MIXER_CHN_LEFT] += -1; + mixer_volume_delta[MIXER_CHN_LEFT] = -1; break; case 'e': - mixer_volume_delta[MIXER_CHN_RIGHT] = 1; case 'E': - mixer_volume_delta[MIXER_CHN_RIGHT] += 1; + mixer_volume_delta[MIXER_CHN_RIGHT] = 1; break; case 'c': - mixer_volume_delta[MIXER_CHN_RIGHT] = -1; case 'C': - mixer_volume_delta[MIXER_CHN_RIGHT] += -1; + mixer_volume_delta[MIXER_CHN_RIGHT] = -1; break; case 'm': case 'M':
At Thu, 2 Apr 2009 18:05:29 +0200, Simon Hengel wrote:
Contrary to what is documented '+' and KEY_UP did not the same thing. The behavior was as follows:
W | + increase volume by 1% w | KEY_UP increase volume by 2% X | - decrease volume by 1% x | KEY_DOWN decrease volume by 2%
Now all of them change the volume by only 1%.
Then rather fix the man page?
Takashi
participants (4)
-
Clemens Ladisch
-
Simon Hengel
-
Simon Hengel
-
Takashi Iwai