Overhauled RSS and weather, added $curl.
[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 WEATHER
99 #include "weather.h"
100 #endif /* WEATHER */
101
102 #ifdef HAVE_LUA
103 #include "llua.h"
104 #endif /* HAVE_LUA */
105
106 #ifdef TCP_PORT_MONITOR
107 #include "tcp-portmon.h"
108 #endif
109
110 #ifdef XMMS2
111 #include "xmms2.h"
112 #endif
113
114 #ifdef IBM
115 #include "ibm.h"
116 #include "smapi.h"
117 #endif
118
119 #ifdef APCUPSD
120 #include "apcupsd.h"
121 #endif
122
123 /* sony support */
124 #include "sony.h"
125
126 /* A size for temporary, static buffers to use when
127  * one doesn't know what to choose. Defaults to 256.  */
128 extern unsigned int text_buffer_size;
129
130 struct entropy_s {
131         unsigned int entropy_avail;
132         unsigned int poolsize;
133 };
134
135 struct usr_info {
136         char *names;
137         char *times;
138         char *terms;
139         int number;
140 };
141
142 struct gateway_info {
143         char *iface;
144         char *ip;
145         int count;
146 };
147
148 #ifdef X11
149 struct monitor_info {
150         int number;
151         int current;
152 };
153
154 struct desktop_info {
155         int current;
156         int number;
157         unsigned int nitems;
158         char *all_names;
159         char *name;
160 };
161
162 struct x11_info {
163         struct monitor_info monitor;
164         struct desktop_info desktop;
165 };
166 #endif
167
168 enum {
169         INFO_CPU = 0,
170         INFO_MAIL = 1,
171         INFO_MEM = 2,
172         INFO_NET = 3,
173         INFO_PROCS = 4,
174         INFO_RUN_PROCS = 5,
175         INFO_UPTIME = 6,
176         INFO_BUFFERS = 7,
177         INFO_FS = 8,
178         INFO_SYSFS = 9,
179         INFO_MIXER = 10,
180         INFO_LOADAVG = 11,
181         INFO_UNAME = 12,
182         INFO_FREQ = 13,
183 #ifdef MPD
184         INFO_MPD = 14,
185 #endif
186         INFO_TOP = 15,
187         INFO_WIFI = 16,
188         INFO_DISKIO = 17,
189         INFO_I8K = 18,
190 #ifdef TCP_PORT_MONITOR
191         INFO_TCP_PORT_MONITOR = 19,
192 #endif
193 #ifdef AUDACIOUS
194         INFO_AUDACIOUS = 20,
195 #endif
196 #ifdef BMPX
197         INFO_BMPX = 21,
198 #endif
199 #ifdef XMMS2
200         INFO_XMMS2 = 22,
201 #endif
202         INFO_ENTROPY = 23,
203 #ifdef IBM
204         INFO_SMAPI = 25,
205 #endif
206         INFO_USERS = 26,
207         INFO_GW = 27,
208 #ifdef NVIDIA
209         INFO_NVIDIA = 28,
210 #endif
211 #ifdef X11
212         INFO_X11 = 29,
213 #endif
214         INFO_DNS = 30,
215 #ifdef MOC
216         INFO_MOC = 31,
217 #endif
218 #ifdef APCUPSD
219         INFO_APCUPSD = 32,
220 #endif
221 #ifdef WEATHER
222         INFO_WEATHER = 33,
223 #endif
224 };
225
226 /* get_battery_stuff() item selector
227  * needed by conky.c, linux.c and freebsd.c */
228 enum {
229         BATTERY_STATUS,
230         BATTERY_TIME
231 };
232
233 /* if_up strictness selector
234  * needed by conky.c and linux.c (and potentially others) */
235 enum {
236         IFUP_UP,
237         IFUP_LINK,
238         IFUP_ADDR
239 } ifup_strictness;
240
241 struct information {
242         unsigned int mask;
243
244         struct utsname uname_s;
245
246         char freq[10];
247
248         double uptime;
249
250         /* memory information in kilobytes */
251         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
252         unsigned long long bufmem, buffers, cached;
253
254         unsigned short procs;
255         unsigned short run_procs;
256
257         float *cpu_usage;
258         /* struct cpu_stat cpu_summed; what the hell is this? */
259         unsigned int cpu_count;
260         int cpu_avg_samples;
261
262         int net_avg_samples;
263
264         int diskio_avg_samples;
265
266         float loadavg[3];
267
268         struct mail_s *mail;
269         int mail_running;
270 #ifdef XMMS2
271         struct xmms2_s xmms2;
272 #endif
273 #ifdef AUDACIOUS
274         AUDACIOUS_S audacious;
275 #endif
276 #ifdef BMPX
277         struct bmpx_s bmpx;
278 #endif
279         struct usr_info users;
280         struct gateway_info gw_info;
281         struct dns_data nameserver_info;
282         struct process *cpu[10];
283         struct process *memu[10];
284         struct process *time[10];
285 #ifdef IOSTATS
286         struct process *io[10];
287 #endif
288         struct process *first_process;
289         unsigned long looped;
290         struct entropy_s entropy;
291         double music_player_interval;
292
293 #ifdef X11
294         struct x11_info x11;
295 #endif
296
297 #ifdef APCUPSD
298         APCUPSD_S apcupsd;
299 #endif
300
301         short kflags;   /* kernel settings, see enum KFLAG */
302 };
303
304 /* needed by linux.c and top.c -> outsource somewhere */
305 enum {
306         /* set to true if kernel uses "long" format for /proc/stats */
307         KFLAG_IS_LONGSTAT = 0x01,
308         /* set to true if kernel shows # of threads for the proc value
309          * in sysinfo() call */
310         KFLAG_PROC_IS_THREADS = 0x02
311         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
312         /* KFLAG_NEXT_ONE = 0x04 */
313 };
314 #define KFLAG_SETON(a) info.kflags |= a
315 #define KFLAG_SETOFF(a) info.kflags &= (~a)
316 #define KFLAG_FLIP(a) info.kflags ^= a
317 #define KFLAG_ISSET(a) info.kflags & a
318
319 /* defined in conky.c, needed by top.c */
320 extern int top_cpu, top_mem, top_time;
321 #ifdef IOSTATS
322 extern int top_io;
323 #endif
324
325 /* defined in conky.c, needed by top.c */
326 extern int cpu_separate;
327
328 /* struct that has all info to be shared between
329  * instances of the same text object */
330 extern struct information info;
331
332 /* defined in users.c */
333 void update_users(void);
334
335 /* defined in conky.c */
336 extern double current_update_time, last_update_time, update_interval;
337
338 /* defined in conky.c */
339 int spaced_print(char *, int, const char *, int, ...)
340         __attribute__((format(printf, 3, 5)));
341 extern int inotify_fd;
342
343 /* defined in conky.c
344  * evaluates 'text' and places the result in 'buffer'
345  */
346 void evaluate(char *text, char *buffer);
347
348 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
349 extern unsigned int max_user_text;
350
351 /* path to config file */
352 extern char *current_config;
353
354 #ifdef X11
355 #define TO_X 1
356 #endif
357 #define TO_STDOUT 2
358 #define TO_STDERR 4
359 #define OVERWRITE_FILE 8
360 #define APPEND_FILE 16
361 enum x_initialiser_state {
362         NO = 0,
363         YES = 1,
364         NEVER = 2
365 };
366 extern int output_methods;
367 extern enum x_initialiser_state x_initialised;
368
369 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
370
371 #endif /* _conky_h_ */