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