2 * alsamixer - curses mixer for the ALSA project
3 * Copyright (c) 1998,1999 Tim Janik
4 * Jaroslav Kysela <perex@perex.cz>
5 * Copyright (c) 2009 Clemens Ladisch <clemens@ladisch.de>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <alsa/asoundlib.h>
27 #include "gettext_curses.h"
28 #include "mixer_widget.h"
31 static int use_color = 1;
32 static struct snd_mixer_selem_regopt selem_regopt = {
34 .abstract = SND_MIXER_SABSTRACT_NONE,
38 static void show_help(void)
40 puts(_("Usage: alsamixer [options]"));
41 puts(_("Useful options:\n"
42 " -h, --help this help\n"
43 " -c, --card=NUMBER sound card number or id\n"
44 " -D, --device=NAME mixer device name\n"
45 " -V, --view=MODE starting view mode: playback/capture/all"));
46 puts(_("Debugging options:\n"
47 " -g, --no-color toggle using of colors\n"
48 " -a, --abstraction=NAME mixer abstraction level: none/basic"));
51 static void parse_options(int argc, char *argv[])
53 static const char short_options[] = "hc:D:V:gsa:";
54 static const struct option long_options[] = {
55 { .name = "help", .val = 'h' },
56 { .name = "card", .has_arg = 1, .val = 'c' },
57 { .name = "device", .has_arg = 1, .val = 'D' },
58 { .name = "view", .has_arg = 1, .val = 'V' },
59 { .name = "no-color", .val = 'g' },
60 { .name = "abstraction", .has_arg = 1, .val = 'a' },
65 static char name_buf[16];
67 while ((option = getopt_long(argc, argv, short_options,
68 long_options, NULL)) != -1) {
75 card_index = snd_card_get_index(optarg);
77 fprintf(stderr, _("invalid card index: %s\n"), optarg);
80 sprintf(name_buf, "hw:%d", card_index);
81 selem_regopt.device = name_buf;
84 selem_regopt.device = optarg;
87 if (*optarg == 'p' || *optarg == 'P')
88 view_mode = VIEW_MODE_PLAYBACK;
89 else if (*optarg == 'c' || *optarg == 'C')
90 view_mode = VIEW_MODE_CAPTURE;
92 view_mode = VIEW_MODE_ALL;
95 use_color = !use_color;
98 if (!strcmp(optarg, "none"))
99 selem_regopt.abstract = SND_MIXER_SABSTRACT_NONE;
100 else if (!strcmp(optarg, "basic"))
101 selem_regopt.abstract = SND_MIXER_SABSTRACT_BASIC;
103 fprintf(stderr, _("unknown abstraction level: %s\n"), optarg);
108 fprintf(stderr, _("unknown option: %c\n"), option);
110 fputs(_("try `alsamixer --help' for more information\n"), stderr);
116 int main(int argc, char *argv[])
118 setlocale(LC_ALL, "");
119 #ifdef ENABLE_NLS_IN_CURSES
123 parse_options(argc, argv);
125 create_mixer_object(&selem_regopt);
127 initialize_curses(use_color);
129 create_mixer_widget();