1 /* tpb - program to use the IBM ThinkPad(tm) special keys
2  * Copyright (C) 2002-2005 Markus Braun <markus.braun@krawel.de>
3  *
4  * This file is part of tpb.
5  *
6  * tpb is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * tpb is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with tpb; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 
21 #ifndef __CFG_H__
22 #define __CFG_H__
23 
24 #if ENABLE_NLS
25 #include <libintl.h>
26 #define _(String) gettext (String)
27 #else /* ENABLE_NLS */
28 #define _(String) (String)
29 #endif /* ENABLE_NLS */
30 
31 enum state {UNDEFINED = -1, STATE_OFF, STATE_ON, STATE_AUTO};
32 enum mode {MODE_COMMENT, MODE_INDENT, MODE_KEYWORD, MODE_SEPARATOR, MODE_ARGUMENT, MODE_END};
33 
34 /* configuration defaults */
35 #define DEFAULT_DAEMON STATE_OFF
36 #define DEFAULT_APM STATE_OFF
37 #define DEFAULT_POWERMGT STATE_AUTO
38 #define DEFAULT_XEVENTS STATE_ON
39 #define DEFAULT_VERBOSE STATE_OFF
40 #define DEFAULT_POLLTIME 200000
41 #define DEFAULT_NVRAMDEV "/dev/nvram"
42 #define DEFAULT_NVRAMDEV_DEVFS "/dev/misc/nvram"
43 #define DEFAULT_MIXER STATE_OFF
44 #define DEFAULT_MIXERSTEPS 14
45 #define DEFAULT_MIXERDEV "/dev/mixer"
46 #ifdef HAVE_LIBXOSD
47 #define DEFAULT_OSD STATE_ON
48 #define DEFAULT_OSDZOOM UNDEFINED
49 #define DEFAULT_OSDTHINKLIGHT UNDEFINED
50 #define DEFAULT_OSDDISPLAY UNDEFINED
51 #define DEFAULT_OSDHVEXPANSION UNDEFINED
52 #define DEFAULT_OSDBRIGHTNESS UNDEFINED
53 #define DEFAULT_OSDVOLUME UNDEFINED
54 #define DEFAULT_OSDPOWERMGT UNDEFINED
55 #define DEFAULT_OSDLINES 2
56 #if HAVE_LIBXOSD_VERSION > 700
57 #define DEFAULT_OSDFONT osd_default_font
58 #else
59 #define DEFAULT_OSDFONT "10x20"
60 #endif /* HAVE_LIBXOSD_VERSION */
61 #define DEFAULT_OSDCOLOR "BLUE"
62 #define DEFAULT_OSDTIMEOUT 3
63 #define DEFAULT_OSDSHADOW 2
64 #define DEFAULT_OSDSHADOWCOLOR "BLACK"
65 #define DEFAULT_OSDOUTLINE 1
66 #define DEFAULT_OSDOUTLINECOLOR "BLACK"
67 #define DEFAULT_OSDVERTICAL 25
68 #define DEFAULT_OSDHORIZONTAL 25
69 #define DEFAULT_OSDPOS XOSD_bottom
70 #define DEFAULT_OSDALIGN XOSD_left
71 #endif /* HAVE_LIBXOSD */
72 
73 /* configuration files */
74 #ifdef SYSCONFDIR
75 #define GLOBAL_CONFIG_FILE SYSCONFDIR "/tpbrc"
76 #else /* SYSCONFDIR */
77 #define GLOBAL_CONFIG_FILE "/usr/local/etc/tpbrc"
78 #endif /* SYSCONFDIR */
79 #define PRIVATE_CONFIG_FILE ".tpbrc"
80 
81 /* Keywords in configuration file */
82 #define CFG_APM "apm"
83 #define CFG_APM_ON "on"
84 #define CFG_APM_OFF "off"
85 #define CFG_POWERMGT "powermgt"
86 #define CFG_POWERMGT_ON "on"
87 #define CFG_POWERMGT_OFF "off"
88 #define CFG_POWERMGT_AUTO "auto"
89 #define CFG_XEVENTS "xevents"
90 #define CFG_XEVENTS_ON "on"
91 #define CFG_XEVENTS_OFF "off"
92 #define CFG_NVRAM "nvram"
93 #define CFG_POLLTIME "polltime"
94 #define CFG_THINKPAD "thinkpad"
95 #define CFG_HOME "home"
96 #define CFG_SEARCH "search"
97 #define CFG_MAIL "mail"
98 #define CFG_WIRELESS "wireless"
99 #define CFG_FAVORITES "favorites"
100 #define CFG_RELOAD "reload"
101 #define CFG_ABORT "abort"
102 #define CFG_BACKWARD "backward"
103 #define CFG_FORWARD "forward"
104 #define CFG_FN "fn"
105 #define CFG_CALLBACK "callback"
106 #define CFG_MIXER "mixer"
107 #define CFG_MIXER_ON "on"
108 #define CFG_MIXER_OFF "off"
109 #define CFG_MIXERSTEPS "mixersteps"
110 #define CFG_MIXERDEV "mixerdevice"
111 #ifdef HAVE_LIBXOSD
112 #define CFG_OSDFONT "osdfont"
113 #define CFG_OSDCOLOR "osdcolor"
114 #define CFG_OSDTIMEOUT "osdtimeout"
115 #define CFG_OSDOFFSET "osdoffset"
116 #define CFG_OSDSHADOW "osdshadow"
117 #if HAVE_LIBXOSD_VERSION >= 20200
118 #define CFG_OSDSHADOWCOLOR "osdshadowcolor"
119 #define CFG_OSDOUTLINE "osdoutline"
120 #define CFG_OSDOUTLINECOLOR "osdoutlinecolor"
121 #endif /* HAVE_LIBXOSD_VERSION */
122 #define CFG_OSDVERTICAL "osdvertical"
123 #define CFG_OSDHORIZONTAL "osdhorizontal"
124 #define CFG_OSDPOS "osdpos"
125 #define CFG_OSDPOS_TOP "top"
126 #define CFG_OSDPOS_MIDDLE "middle"
127 #define CFG_OSDPOS_BOTTOM "bottom"
128 #define CFG_OSDALIGN "osdalign"
129 #define CFG_OSDALIGN_LEFT "left"
130 #define CFG_OSDALIGN_CENTER "center"
131 #define CFG_OSDALIGN_RIGHT "right"
132 #define CFG_OSD "osd"
133 #define CFG_OSD_ON "on"
134 #define CFG_OSD_OFF "off"
135 #define CFG_OSDZOOM "osdzoom"
136 #define CFG_OSDZOOM_ON "on"
137 #define CFG_OSDZOOM_OFF "off"
138 #define CFG_OSDTHINKLIGHT "osdthinklight"
139 #define CFG_OSDTHINKLIGHT_ON "on"
140 #define CFG_OSDTHINKLIGHT_OFF "off"
141 #define CFG_OSDDISPLAY "osddisplay"
142 #define CFG_OSDDISPLAY_ON "on"
143 #define CFG_OSDDISPLAY_OFF "off"
144 #define CFG_OSDHVEXPANSION "osdhvexpansion"
145 #define CFG_OSDHVEXPANSION_ON "on"
146 #define CFG_OSDHVEXPANSION_OFF "off"
147 #define CFG_OSDBRIGHTNESS "osdbrightness"
148 #define CFG_OSDBRIGHTNESS_ON "on"
149 #define CFG_OSDBRIGHTNESS_OFF "off"
150 #define CFG_OSDVOLUME "osdvolume"
151 #define CFG_OSDVOLUME_ON "on"
152 #define CFG_OSDVOLUME_OFF "off"
153 #define CFG_OSDPOWERMGT "osdpowermgt"
154 #define CFG_OSDPOWERMGT_ON "on"
155 #define CFG_OSDPOWERMGT_OFF "off"
156 #endif /* HAVE_LIBXOSD */
157 
158 #define BUFFER_SIZE 256
159 
160 typedef struct {
161   int daemon;
162   int apm;
163   int powermgt;
164   int xevents;
165   char *nvram;
166   int polltime;
167   char *tpb_cmd;
168   char *home_cmd;
169   char *search_cmd;
170   char *mail_cmd;
171   char *wireless_cmd;
172   char *favorites_cmd;
173   char *reload_cmd;
174   char *abort_cmd;
175   char *backward_cmd;
176   char *forward_cmd;
177   char *fn_cmd;
178   char *callback;
179   int mixer;
180   int mixersteps;
181   char *mixerdev;
182   int verbose;
183 #ifdef HAVE_LIBXOSD
184   int osd;
185   int osdzoom;
186   int osdthinklight;
187   int osddisplay;
188   int osdhvexpansion;
189   int osdbrightness;
190   int osdvolume;
191   int osdpowermgt;
192   char *osdfont;
193   char *osdcolor;
194   int osdtimeout;
195   int osdshadow;
196 #if HAVE_LIBXOSD_VERSION >= 20200
197   char *osdshadowcolor;
198   int osdoutline;
199   char *osdoutlinecolor;
200 #endif /* HAVE_LIBXOSD_VERSION */
201   int osdvertical;
202   int osdhorizontal;
203   xosd_pos osdpos;
204 #if HAVE_LIBXOSD_VERSION >= 10000
205   xosd_align osdalign;
206 #endif /* HAVE_LIBXOSD_VERSION */
207 #endif /* HAVE_LIBXOSD */
208 } config;
209 
210 int parse_cfg_file(config *cfg, char *name);
211 void parse_option(config *cfg, int argc, char **argv);
212 void init_cfg(config *cfg);
213 void clear_cfg(config *cfg);
214 void free_cfg(config *cfg);
215 void override_cfg(config *master, config *slave);
216 void set_value(char *key, char *arg, config *cfg);
217 void print_usage(const char *prog);
218 
219 #endif /* __CFG_H__ */
220 
221 /* vim600:set fen:set fdm=marker:set fdl=0: */
222