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