Move vi modelines closer to the beginning, so they're more likely to be actually...
[monky] / src / conky.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  * vim: ts=4 sw=4 noet ai cindent syntax=c
3  *
4  * Conky, a system monitor, based on torsmo
5  *
6  * Any original torsmo code is licensed under the BSD license
7  *
8  * All code written since the fork of torsmo is licensed under the GPL
9  *
10  * Please see COPYING for details
11  *
12  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
13  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
14  *      (see AUTHORS)
15  * All rights reserved.
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  * You should have received a copy of the GNU General Public License
27  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28  *
29  */
30
31 #ifndef _conky_h_
32 #define _conky_h_
33
34 #include "config.h"     /* defines */
35 #include "common.h"     /* at least for struct dns_data */
36 #include <sys/utsname.h> /* struct uname_s */
37 #include <arpa/inet.h>
38
39 #if defined(HAS_MCHECK_H)
40 #include <mcheck.h>
41 #endif /* HAS_MCHECK_H */
42
43 #undef EQUAL
44 #undef FALSE
45 #undef TRUE
46 #define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
47 #define FALSE 0
48 #define TRUE 1
49
50 #define DEFAULT_BAR_WIDTH_NO_X 10
51
52 #if !defined(__GNUC__)
53 #  define __attribute__(x) /* nothing */
54 #endif
55
56 #ifndef HAVE_STRNDUP
57 // use our own strndup() if it's not available
58 char *strndup(const char *s, size_t n);
59 #endif /* HAVE_STRNDUP */
60
61 /* headers of optional features
62  * include them here, so we don't need to run the check
63  * in every code file optionally using the feature
64  */
65
66 #ifdef AUDACIOUS
67 #include "audacious.h"
68 #endif
69
70 #ifdef BMPX
71 #include "bmpx.h"
72 #endif
73
74 #ifdef EVE
75 #include "eve.h"
76 #endif
77
78 #ifdef HDDTEMP
79 #include "hddtemp.h"
80 #endif /* HDDTEMP */
81
82 #ifdef MOC
83 #include "moc.h"
84 #endif
85
86 #ifdef MPD
87 #include "mpd.h"
88 #endif
89
90 #ifdef NVIDIA
91 #include "nvidia.h"
92 #endif
93
94 #ifdef HAVE_CURL
95 #include "ccurl_thread.h"
96 #endif /* HAVE_CURL */
97
98 #ifdef RSS
99 #include "rss.h"
100 #endif /* RSS */
101
102 #ifdef XOAP
103 #ifndef WEATHER
104 #error "WEATHER needs to be defined if XOAP is defined"
105 #endif /* WEATHER */
106 #endif /* XOAP */
107
108 #ifdef WEATHER
109 #include "weather.h"
110 #endif /* WEATHER */
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
173 int get_stippled_borders(void);
174
175 #endif /* X11 */
176
177 /* defined in conky.c */
178 extern long default_fg_color, default_bg_color, default_out_color;
179 extern long color0, color1, color2, color3, color4, color5, color6, color7,
180            color8, color9;
181 void set_current_text_color(long colour);
182 long get_current_text_color(void);
183
184 void set_updatereset(int);
185 int get_updatereset(void);
186
187 struct conftree {
188         char* string;
189         struct conftree* horz_next;
190         struct conftree* vert_next;
191         struct conftree* back;
192 };
193
194 char load_config_file(const char *);
195
196 char *get_global_text(void);
197 extern long global_text_lines;
198
199 //adds newstring to to the tree unless you can already see it when travelling back.
200 //if it's possible to attach it then it returns a pointer to the leaf, else it returns NULL
201 struct conftree* conftree_add(struct conftree* previous, const char* newstring);
202
203 extern struct conftree *currentconffile;
204
205 #define MAX_TEMPLATES 10
206 char **get_templates(void);
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, swapfree, 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 #ifdef IOSTATS
268         struct process *io[10];
269 #endif
270         struct process *first_process;
271         unsigned long looped;
272         struct entropy_s entropy;
273         double music_player_interval;
274
275 #ifdef X11
276         struct x11_info x11;
277 #endif
278
279 #ifdef APCUPSD
280         APCUPSD_S apcupsd;
281 #endif
282
283         short kflags;   /* kernel settings, see enum KFLAG */
284 };
285
286 #ifdef HAVE_LUA
287 #include "llua.h"
288 #endif /* HAVE_LUA */
289
290 /* needed by linux.c and top.c -> outsource somewhere */
291 enum {
292         /* set to true if kernel uses "long" format for /proc/stats */
293         KFLAG_IS_LONGSTAT = 0x01,
294         /* set to true if kernel shows # of threads for the proc value
295          * in sysinfo() call */
296         KFLAG_PROC_IS_THREADS = 0x02
297         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
298         /* KFLAG_NEXT_ONE = 0x04 */
299 };
300 #define KFLAG_SETON(a) info.kflags |= a
301 #define KFLAG_SETOFF(a) info.kflags &= (~a)
302 #define KFLAG_FLIP(a) info.kflags ^= a
303 #define KFLAG_ISSET(a) info.kflags & a
304
305 /* defined in conky.c, needed by top.c */
306 extern int top_cpu, top_mem, top_time;
307 #ifdef IOSTATS
308 extern int top_io;
309 #endif
310 #ifdef __linux__
311 extern int top_running;
312 #endif
313
314 /* defined in conky.c, needed by top.c */
315 extern int cpu_separate;
316
317 /* struct that has all info to be shared between
318  * instances of the same text object */
319 extern struct information info;
320
321 /* defined in users.c */
322 void update_users(void);
323
324 /* defined in conky.c */
325 extern double current_update_time, last_update_time, update_interval;
326
327 /* defined in conky.c */
328 int spaced_print(char *, int, const char *, int, ...)
329         __attribute__((format(printf, 3, 5)));
330 extern int inotify_fd;
331
332 /* defined in conky.c
333  * evaluates 'text' and places the result in 'buffer'
334  */
335 void evaluate(const char *text, char *buffer);
336
337 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
338 extern unsigned int max_user_text;
339
340 /* path to config file */
341 extern char *current_config;
342
343 /* just a wrapper for read_exec() defined in conky.c */
344 void do_read_exec(const char *data, char *buf, const int size);
345
346 #ifdef X11
347 #define TO_X 1
348 #endif /* X11 */
349 #define TO_STDOUT 2
350 #define TO_STDERR 4
351 #define OVERWRITE_FILE 8
352 #define APPEND_FILE 16
353 #ifdef NCURSES
354 #define TO_NCURSES 32
355 #endif /* NCURSES */
356 enum x_initialiser_state {
357         NO = 0,
358         YES = 1,
359         NEVER = 2
360 };
361 extern int output_methods;
362 extern enum x_initialiser_state x_initialised;
363
364 void set_update_interval(double interval);
365
366 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
367
368 #define NOBATTERY 0
369
370 /* to get rid of 'unused variable' warnings */
371 #define UNUSED(a)  (void)a
372 #define UNUSED_ATTR __attribute__ ((unused))
373
374 #endif /* _conky_h_ */