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