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