textbox.c, mixer_display.c:
- Replaced manual line drawing code `for (...) mvwaddch(...)` by the
functions `mvwhline/mvwvline` provided by standard curses
card_select.c, proc_files.c:
- Moved duplicate code in the create() functions to menu_widget_create()
in menu_widget.c
card_select.c:
- Removed redundant calls to sprintf()
device_name.c:
- Combined multiple calls to form_opts_off()
- Recognize ASCII DEL (127) as backspace
widget.c:
- Uncommented code for setting a dummy key handler (all existing
widgets do provide a key handling function)
Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Added configparser.c and curskey.c:
- Lines starting with arbitrary whitespace + '#' are comments
- Words in a command name don't have a fixed order (toggle_mute is the
same as mute_toggle)
Moved read_file() from textbox.c to utils.c, so configparser.c can make
use of it.
Added command line options:
-f/-F to specify/disable configuration file
-m/-M to enable/disable mouse
Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is a preparation for the configuration file parser.
The `int attr_*` variables have been moved into a separate struct.
Members of that struct are alphabetically ordered, so an attribute can
later be accessed by its name.
Added `int get_color_pair(short fg, short bg)` for returning or
creating a color pair number.
Added call to `use_default_colors()` for enabling access to the
terminal's default color (-1).
Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Mouse support has been added for mixer_widget.c, card_select.c and
proc_files.c.
In the mixer widget the mouse is handled as follows:
- After an element has been printed in mixer_display.c, a call to
clickable_set() will store the coordinates of the drawn area plus the
command enum that should be executed on click. An optional argument
holds an index which points to the selected mixer control.
- on_mouse_click() searches for a matching rectangle, focuses the mixer
control and returns the command enum.
In the menu widgets, the menu_driver() function handles mouse input.
Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is a preparation for making keybindings configurable.
The hardcoded keys in the switch statements of mixer_widget.c,
textbox.c, proc_files.c and card_select.c have been replaced by
command enums. The command that shall be executed is looked up in
the arrays `mixer_bindings` and `textbox_bindings`.
The channel_mask enum has been made public, since LEFT and RIGHT are
used as command arguments in bindings.c.
Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Obtaining the new window size using TIOCGWINSZ and setting it using
resize_term(), so getmaxyx() reports the actual terminal size.
Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
To zero-initialize an object, use `{0}` instead.
Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
exp10 is a GNU extension and not available everywhere (eg. uClibc-ng).
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Fixes Master, Headphones and Speaker stuck at -8 percentage after
building with Clang 7.0.1 and getting warned about implicit declaration
of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks
Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is
not affected, so not adding a compiler check to the configure script.
uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer
needed. However, alsa-utils relies on gettext so might need further
patches to actually work on uClibc systems.
Signed-off-by: makepost <makepost@firemail.cc>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
When we get a notification that an element has been removed, we have to
recreate our internal control representation to avoid accessing freed
memory. (And the checking for SND_CTL_EVENT_MASK_REMOVE should actually
be done correctly while we're at it.)
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
A lot of reports that alsamixer crashes in X terminal when the PulseAudio
CTL plugin is activated were entered to the tracking systems.
I figured that there is a linking clash for the shutdown() function.
The shutdown() function in glibc is socket related, but the alsamixer code
redefines this function and appearently that under some linking
circumstances - which PA client invokes during the runtime dynamic linking
- the wrong function is called.
This patch, for safety, renames the shutdown() function from alsamixer
to app_shutdown(), but it might make sense to figure the real linking
culprit to avoid future surprises.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
exp10 is a glibc extension, which isn't supported on uClibc. Luckily,
exp10() is trivial to compute based on exp(), so add a wrapper for
the uClibc case.
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Instead of mapping the raw volume values linearly to the screen, use
a mapping where the bar height is proportional to the audible volume,
i.e., where the amplitude is the cube of the bar height.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
For controls with a big range, stepping through all values can become
tedious and make it impossible to adjust the volume easily. Therefore,
ensure that all steps are big enough so that the full range has at most
one hundred steps.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Ensure that control volume values are in their allowed range; otherwise,
the displayed values could be outside the range 0..100 and mess up the
layout.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
The attempt to divide by max-min fails if a control has only one valid
value. In this case, adjust the maximum so that the computation can
succeed; the control will look like 0%.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Fix the volume bar color selection logic so that the current attribute
is used for inactive controls.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Rename the attr variable because it contains not only the character's
attributes but also the character itself.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
When a multi-column character would straddle the left window border of
a text box, we have to take the inserted space character into account
when we compute how many characters fit into the rest of the line.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
For multichannel mixer controls, add the channel name to each screen
control.
Also make some other small changes.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
* 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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
By doing this we move them from the .data section to .rodata setion,
or from .data.rel to .data.rel.ro.
The .rodata section is mapped directly from the on-disk file, which is
always a save, while .data.rel.ro is mapped directly when using
prelink, which is a save in a lot of cases.
Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
The recent ncurses package provides ncurses*-config program to give the
proper cflags and libs. Let's use them if available.
Right now, the ncurses version (5) is hard-coded. It should be better
to be variable as well, but it'd be messy. Hope the ncurses version won't
change rapidly.
DONE: If alsa-lib and alsa-driver support it,
alsamixer now displays dB gain levels for all mixer controls.
TODO: Implement alsa-lib and alsa-driver parts.