1 /* WMix -- a mixer using the OSS mixer API.
2 * Copyright (C) 2014 Christophe CURIS for the WindowMaker Team
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * config.c: functions related to loading the configuration from file
26 #include <sys/soundcard.h>
28 #include "include/common.h"
29 #include "include/config.h"
32 /* The global configuration */
33 struct _Config config
;
37 * Read configuration from a file
39 * The file name is taken from CLI if available, of falls back to
42 void config_read(void)
48 if (config
.file
== NULL
)
51 fp
= fopen(config
.file
, "r");
55 while (fgets(buf
, 512, fp
)) {
56 if ((ptr
= strstr(buf
, "mousewheel="))) {
58 config
.mousewheel
= atoi(ptr
);
60 if ((ptr
= strstr(buf
, "scrolltext="))) {
62 config
.scrolltext
= atoi(ptr
);
64 if ((ptr
= strstr(buf
, "osd="))) {
66 config
.osd
= atoi(ptr
);
68 if ((ptr
= strstr(buf
, "osdcolor="))) {
71 end
= strchr(ptr
, '\n');
72 ptr
[end
- ptr
] = '\0';
74 free(config
.osd_color
);
75 config
.osd_color
= strdup(ptr
);
77 if ((ptr
= strstr(buf
, "wheelstep="))) {
79 /* detect old style config */
81 config
.scrollstep
= (float)atoi(ptr
) / 100.0;
83 config
.scrollstep
= atof(ptr
);
85 if ((ptr
= strstr(buf
, "wheelbtn1="))) {
87 config
.wheel_button_up
= atoi(ptr
);
89 if ((ptr
= strstr(buf
, "wheelbtn2="))) {
91 config
.wheel_button_down
= atoi(ptr
);