Fix: If there is no battery then we don't care about the status
[monky] / src / conky.h
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
10  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
11  *      (see AUTHORS)
12  * All rights reserved.
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27
28 #ifndef _conky_h_
29 #define _conky_h_
30
31 #include "config.h"     /* defines */
32 #include "common.h"     /* at least for struct dns_data */
33 #include <sys/utsname.h> /* struct uname_s */
34
35 #if defined(HAS_MCHECK_H)
36 #include <mcheck.h>
37 #endif /* HAS_MCHECK_H */
38
39 #undef EQUAL
40 #undef FALSE
41 #undef TRUE
42 #define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
43 #define FALSE 0
44 #define TRUE 1
45
46 #define DEFAULT_BAR_WIDTH_NO_X 10
47
48 #if !defined(__GNUC__)
49 #  define __attribute__(x) /* nothing */
50 #endif
51
52 #ifndef HAVE_STRNDUP
53 // use our own strndup() if it's not available
54 char *strndup(const char *s, size_t n);
55 #endif /* HAVE_STRNDUP */
56
57 /* headers of optional features
58  * include them here, so we don't need to run the check
59  * in every code file optionally using the feature
60  */
61
62 #ifdef AUDACIOUS
63 #include "audacious.h"
64 #endif
65
66 #ifdef BMPX
67 #include "bmpx.h"
68 #endif
69
70 #ifdef EVE
71 #include "eve.h"
72 #endif
73
74 #ifdef HDDTEMP
75 #include "hddtemp.h"
76 #endif /* HDDTEMP */
77
78 #ifdef MOC
79 #include "moc.h"
80 #endif
81
82 #ifdef MPD
83 #include "mpd.h"
84 #endif
85
86 #ifdef NVIDIA
87 #include "nvidia.h"
88 #endif
89
90 #ifdef HAVE_CURL
91 #include "ccurl_thread.h"
92 #endif /* HAVE_CURL */
93
94 #ifdef RSS
95 #include "rss.h"
96 #endif /* RSS */
97
98 #ifdef XOAP
99 #ifndef WEATHER
100 #error "WEATHER needs to be defined if XOAP is defined"
101 #endif /* WEATHER */
102 #endif /* XOAP */
103
104 #ifdef WEATHER
105 #include "weather.h"
106 #endif /* WEATHER */
107
108 #ifdef HAVE_LUA
109 #include "llua.h"
110 #endif /* HAVE_LUA */
111
112 #ifdef TCP_PORT_MONITOR
113 #include "tcp-portmon.h"
114 #endif
115
116 #ifdef XMMS2
117 #include "xmms2.h"
118 #endif
119
120 #ifdef IBM
121 #include "ibm.h"
122 #include "smapi.h"
123 #endif
124
125 #ifdef APCUPSD
126 #include "apcupsd.h"
127 #endif
128
129 /* sony support */
130 #include "sony.h"
131
132 /* A size for temporary, static buffers to use when
133  * one doesn't know what to choose. Defaults to 256.  */
134 extern unsigned int text_buffer_size;
135
136 struct entropy_s {
137         unsigned int entropy_avail;
138         unsigned int poolsize;
139 };
140
141 struct usr_info {
142         char *names;
143         char *times;
144         char *terms;
145         int number;
146 };
147
148 struct gateway_info {
149         char *iface;
150         char *ip;
151         int count;
152 };
153
154 #ifdef X11
155 struct monitor_info {
156         int number;
157         int current;
158 };
159
160 struct desktop_info {
161         int current;
162         int number;
163         unsigned int nitems;
164         char *all_names;
165         char *name;
166 };
167
168 struct x11_info {
169         struct monitor_info monitor;
170         struct desktop_info desktop;
171 };
172 #endif
173
174 enum {
175         INFO_CPU = 0,
176         INFO_MAIL = 1,
177         INFO_MEM = 2,
178         INFO_NET = 3,
179         INFO_PROCS = 4,
180         INFO_RUN_PROCS = 5,
181         INFO_UPTIME = 6,
182         INFO_BUFFERS = 7,
183         INFO_FS = 8,
184         INFO_SYSFS = 9,
185         INFO_MIXER = 10,
186         INFO_LOADAVG = 11,
187         INFO_UNAME = 12,
188         INFO_FREQ = 13,
189 #ifdef MPD
190         INFO_MPD = 14,
191 #endif
192         INFO_TOP = 15,
193         INFO_WIFI = 16,
194         INFO_DISKIO = 17,
195         INFO_I8K = 18,
196 #ifdef TCP_PORT_MONITOR
197         INFO_TCP_PORT_MONITOR = 19,
198 #endif
199 #ifdef AUDACIOUS
200         INFO_AUDACIOUS = 20,
201 #endif
202 #ifdef BMPX
203         INFO_BMPX = 21,
204 #endif
205 #ifdef XMMS2
206         INFO_XMMS2 = 22,
207 #endif
208         INFO_ENTROPY = 23,
209 #ifdef IBM
210         INFO_SMAPI = 25,
211 #endif
212         INFO_USERS = 26,
213         INFO_GW = 27,
214 #ifdef NVIDIA
215         INFO_NVIDIA = 28,
216 #endif
217 #ifdef X11
218         INFO_X11 = 29,
219 #endif
220         INFO_DNS = 30,
221 #ifdef MOC
222         INFO_MOC = 31,
223 #endif
224 #ifdef APCUPSD
225         INFO_APCUPSD = 32,
226 #endif
227 #ifdef WEATHER
228         INFO_WEATHER = 33,
229 #endif
230 };
231
232 /* get_battery_stuff() item selector
233  * needed by conky.c, linux.c and freebsd.c */
234 enum {
235         BATTERY_STATUS,
236         BATTERY_TIME
237 };
238
239 /* if_up strictness selector
240  * needed by conky.c and linux.c (and potentially others) */
241 enum {
242         IFUP_UP,
243         IFUP_LINK,
244         IFUP_ADDR
245 } ifup_strictness;
246
247 struct information {
248         unsigned int mask;
249
250         struct utsname uname_s;
251
252         char freq[10];
253
254         double uptime;
255
256         /* memory information in kilobytes */
257         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
258         unsigned long long bufmem, buffers, cached;
259
260         unsigned short procs;
261         unsigned short run_procs;
262
263         float *cpu_usage;
264         /* struct cpu_stat cpu_summed; what the hell is this? */
265         unsigned int cpu_count;
266         int cpu_avg_samples;
267
268         int net_avg_samples;
269
270         int diskio_avg_samples;
271
272         float loadavg[3];
273
274         struct mail_s *mail;
275         int mail_running;
276 #ifdef XMMS2
277         struct xmms2_s xmms2;
278 #endif
279 #ifdef AUDACIOUS
280         AUDACIOUS_S audacious;
281 #endif
282 #ifdef BMPX
283         struct bmpx_s bmpx;
284 #endif
285         struct usr_info users;
286         struct gateway_info gw_info;
287         struct dns_data nameserver_info;
288         struct process *cpu[10];
289         struct process *memu[10];
290         struct process *time[10];
291 #ifdef IOSTATS
292         struct process *io[10];
293 #endif
294         struct process *first_process;
295         unsigned long looped;
296         struct entropy_s entropy;
297         double music_player_interval;
298
299 #ifdef X11
300         struct x11_info x11;
301 #endif
302
303 #ifdef APCUPSD
304         APCUPSD_S apcupsd;
305 #endif
306
307         short kflags;   /* kernel settings, see enum KFLAG */
308 };
309
310 /* needed by linux.c and top.c -> outsource somewhere */
311 enum {
312         /* set to true if kernel uses "long" format for /proc/stats */
313         KFLAG_IS_LONGSTAT = 0x01,
314         /* set to true if kernel shows # of threads for the proc value
315          * in sysinfo() call */
316         KFLAG_PROC_IS_THREADS = 0x02
317         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
318         /* KFLAG_NEXT_ONE = 0x04 */
319 };
320 #define KFLAG_SETON(a) info.kflags |= a
321 #define KFLAG_SETOFF(a) info.kflags &= (~a)
322 #define KFLAG_FLIP(a) info.kflags ^= a
323 #define KFLAG_ISSET(a) info.kflags & a
324
325 /* defined in conky.c, needed by top.c */
326 extern int top_cpu, top_mem, top_time;
327 #ifdef IOSTATS
328 extern int top_io;
329 #endif
330
331 /* defined in conky.c, needed by top.c */
332 extern int cpu_separate;
333
334 /* struct that has all info to be shared between
335  * instances of the same text object */
336 extern struct information info;
337
338 /* defined in users.c */
339 void update_users(void);
340
341 /* defined in conky.c */
342 extern double current_update_time, last_update_time, update_interval;
343
344 /* defined in conky.c */
345 int spaced_print(char *, int, const char *, int, ...)
346         __attribute__((format(printf, 3, 5)));
347 extern int inotify_fd;
348
349 /* defined in conky.c
350  * evaluates 'text' and places the result in 'buffer'
351  */
352 void evaluate(char *text, char *buffer);
353
354 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
355 extern unsigned int max_user_text;
356
357 /* path to config file */
358 extern char *current_config;
359
360 #ifdef X11
361 #define TO_X 1
362 #endif
363 #define TO_STDOUT 2
364 #define TO_STDERR 4
365 #define OVERWRITE_FILE 8
366 #define APPEND_FILE 16
367 enum x_initialiser_state {
368         NO = 0,
369         YES = 1,
370         NEVER = 2
371 };
372 extern int output_methods;
373 extern enum x_initialiser_state x_initialised;
374
375 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
376
377 #define NOBATTERY 0
378
379 #endif /* _conky_h_ */