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