dum de dum
[monky] / conky.h
1 #ifndef _conky_h_
2 #define _conky_h_
3
4 //#include <mcheck.h>
5 #include "config.h"
6 #include <sys/utsname.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <locale.h>
10 #include <langinfo.h>
11 #include <wchar.h>
12
13 #if defined(HAVE_CAIRO_H) && defined(HAVE_CAIRO_XLIB_H) && defined(WANT_CAIRO)
14 #define CAIRO
15 #include <X11/Xlib.h>
16 #include <X11/Xutil.h>
17 #include <cairo.h>
18 #include <cairo-xlib.h>
19 #endif
20
21 #define TOP_CPU 1
22 #define TOP_NAME 2
23 #define TOP_PID 3
24 #define TOP_MEM 4
25
26 #define TEXT_BUFFER_SIZE 1024
27
28 #ifdef METAR
29 #include <metar.h>
30 #endif
31
32 #include <sys/socket.h>
33
34 #define ERR(s, varargs...) \
35 fprintf(stderr, "Conky: " s "\n", ##varargs)
36
37 /* critical error */
38 #define CRIT_ERR(s, varargs...) \
39 { fprintf(stderr, "Conky: " s "\n", ##varargs);  exit(EXIT_FAILURE); }
40
41 struct net_stat {
42         const char *dev;
43         int up;
44         long long last_read_recv, last_read_trans;
45         long long recv, trans;
46         double recv_speed, trans_speed;
47         struct sockaddr addr;
48         int linkstatus;
49         double net_rec[15], net_trans[15];
50 };
51
52 struct fs_stat {
53         int fd;
54         char *path;
55         long long size;
56         long long avail;
57 };
58
59 struct cpu_stat {
60         unsigned int user, nice, system, idle, iowait, irq, softirq;
61         int cpu_avg_samples;
62 };
63
64 #ifdef MPD
65 struct mpd_s {
66         char *title;
67         char *artist;
68         char *album;
69         char *status;
70         int volume;
71         unsigned int port;
72         char host[128];
73         float progress;
74         int bitrate;
75 };
76 #endif
77
78 enum {
79         INFO_CPU = 0,
80         INFO_MAIL = 1,
81         INFO_MEM = 2,
82         INFO_NET = 3,
83 #ifdef SETI
84         INFO_SETI = 4,
85 #endif
86         INFO_PROCS = 5,
87         INFO_RUN_PROCS = 6,
88         INFO_UPTIME = 7,
89         INFO_BUFFERS = 8,
90         INFO_FS = 9,
91         INFO_I2C = 10,
92         INFO_MIXER = 11,
93         INFO_LOADAVG = 12,
94         INFO_UNAME = 13,
95         INFO_FREQ = 14,
96 #ifdef MPD
97         INFO_MPD = 15,
98 #endif
99         INFO_TOP = 16,
100 #ifdef METAR
101         INFO_METAR     = 17,
102 #endif
103 #ifdef MLDONKEY
104         INFO_MLDONKEY = 18,
105 #endif
106         INFO_WIFI = 19,
107 };
108
109
110 #ifdef MPD
111 #include "libmpdclient.h"
112 #endif
113
114 struct information {
115         unsigned int mask;
116
117         struct utsname uname_s;
118
119         char freq[10];
120
121         double uptime;
122
123         /* memory information in kilobytes */
124         unsigned int mem, memmax, swap, swapmax;
125         unsigned int bufmem, buffers, cached;
126
127         unsigned int procs;
128         unsigned int run_procs;
129
130         float cpu_usage;
131         struct cpu_stat cpu_summed;
132         unsigned int cpu_count;
133         unsigned int cpu_avg_samples;
134
135         unsigned int net_avg_samples;
136
137         float loadavg[3];
138
139         int new_mail_count, mail_count;
140 #ifdef SETI
141         float seti_prog;
142         float seti_credit;
143 #endif
144 #ifdef MPD
145         struct mpd_s mpd;
146         mpd_Connection *conn;
147 #endif
148         struct process *cpu[10];
149         struct process *memu[10];
150         unsigned long looped;
151 };
152
153 /* in x11.c */
154
155 #include <X11/Xlib.h>
156 #include <X11/Xlib.h>
157 #include <X11/Xatom.h>
158
159 #ifdef XFT
160 #include <X11/Xft/Xft.h>
161 #endif
162
163 #if defined(HAVE_XDBE) && defined(DOUBLE_BUFFER)
164 #define XDBE
165 #include <X11/extensions/Xdbe.h>
166 #endif
167
168 #define ATOM(a) XInternAtom(display, #a, False)
169
170 struct conky_window {
171         Window window;
172         Drawable drawable;
173         GC gc;
174 #ifdef XDBE
175         XdbeBackBuffer back_buffer;
176 #endif
177 #ifdef XFT
178         XftDraw *xftdraw;
179 #endif
180
181         int width;
182         int height;
183 #ifdef OWN_WINDOW
184         int x;
185         int y;
186 #endif
187 };
188
189 #ifdef XDBE
190 extern int use_xdbe;
191 #endif
192
193 int out_to_console;
194
195 int top_cpu;
196 int top_mem;
197
198 int use_spacer;
199
200 char *tmpstring1;
201 char *tmpstring2;
202
203 #ifdef XFT
204 extern int use_xft;
205 #endif
206
207 extern Display *display;
208 extern int display_width;
209 extern int display_height;
210 extern int screen;
211
212 extern int workarea[4];
213
214 extern struct conky_window window;
215
216 void init_X11();
217 void init_window(int use_own_window, int width, int height);
218 void create_gc();
219 void set_transparent_background(Window win);
220 long get_x11_color(const char *);
221
222 /* in common.c */
223
224 /* struct that has all info */
225 struct information info;
226
227 void update_uname();
228 double get_time(void);
229 FILE *open_file(const char *file, int *reported);
230 void variable_substitute(const char *s, char *dest, unsigned int n);
231 void format_seconds(char *buf, unsigned int n, long t);
232 void format_seconds_short(char *buf, unsigned int n, long t);
233 struct net_stat *get_net_stat(const char *dev);
234
235 void update_stuff();
236
237 #define SET_NEED(a) need_mask |= 1 << (a)
238 extern unsigned int need_mask;
239
240 extern double current_update_time, last_update_time;
241
242 extern int no_buffers;
243
244 /* system dependant (in linux.c) */
245
246 void prepare_update(void);
247 void update_uptime(void);
248 void update_meminfo(void);
249 void update_net_stats(void);
250 void update_wifi_stats(void);
251 void update_cpu_usage(void);
252 void update_total_processes(void);
253 void update_running_processes(void);
254 char *get_freq();
255 void update_load_average();
256 int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
257                     char *devtype);
258 double get_i2c_info(int *fd, int arg, char *devtype, char *type);
259
260 char *get_adt746x_cpu(void);
261 char *get_adt746x_fan(void);
262
263 int open_acpi_temperature(const char *name);
264 double get_acpi_temperature(int fd);
265 char *get_acpi_ac_adapter(void);
266 char *get_acpi_fan(void);
267 void get_battery_stuff(char *buf, unsigned int n, const char *bat);
268
269 struct process {
270         struct process *next;
271         struct process *previous;
272
273         pid_t pid;
274         char *name;
275         float amount;
276         unsigned int user_time;
277         unsigned int total;
278         unsigned int kernel_time;
279         unsigned int previous_user_time;
280         unsigned int previous_kernel_time;
281         unsigned int vsize;
282         unsigned int rss;
283         unsigned int time_stamp;
284         unsigned int counted;
285         unsigned int changed;
286         float totalmem;
287 };
288
289 #ifdef METAR
290 double last_metar_update;
291 extern char *metar_station;
292 extern char *metar_server;
293 extern char *metar_path;
294 extern char ftp_ok;
295 extern char metar_worked;
296 extern Decoded_METAR data;
297
298 extern int calculateRelativeHumidity(int, int);
299 extern int calculateWindChill(int, int);
300 extern int knTokph(int);
301 extern const char *calculateWindDirectionString(int);
302 extern const char *calculateShortWindDirectionString(int);
303
304 void update_metar();
305 #endif
306
307
308
309 void update_top();
310
311
312 /* fs-stuff is possibly system dependant (in fs.c) */
313
314 void update_fs_stats(void);
315 struct fs_stat *prepare_fs_stat(const char *path);
316 void clear_fs_stats(void);
317
318 /* in mixer.c */
319
320 int mixer_init(const char *);
321 int mixer_get_avg(int);
322 int mixer_get_left(int);
323 int mixer_get_right(int);
324
325 /* in mail.c */
326
327 extern char *current_mail_spool;
328
329 void update_mail_count();
330
331 /* in seti.c */
332
333 #ifdef SETI
334 extern char *seti_dir;
335
336 void update_seti();
337 #endif
338
339 /* in mpd.c */
340
341 #ifdef MPD
342 void update_mpd();
343 #endif
344
345 #ifdef MLDONKEY
346 /* in mldonkey.c */
347 typedef long long int64;
348 /* The info necessary to connect to mldonkey. login and password can be NULL. */
349 typedef struct mldonkey_config {
350         char *mldonkey_hostname;
351         int mldonkey_port;
352         char *mldonkey_login;
353         char *mldonkey_password;
354 } mldonkey_config;
355
356 /* The MLDonkey status returned */
357 typedef struct mldonkey_info {
358         int64  upload_counter;
359         int64 download_counter;
360         int nshared_files;
361         int64 shared_counter;
362         int  tcp_upload_rate;
363         int  tcp_download_rate;
364         int  udp_upload_rate;
365         int  udp_download_rate;
366         int  ndownloaded_files;
367         int ndownloading_files;
368         int nconnected_networks;
369         int connected_networks[1];
370 } mldonkey_info;
371         
372 extern mldonkey_info mlinfo;
373 extern mldonkey_config mlconfig;
374         
375 int get_mldonkey_status(mldonkey_config *config, mldonkey_info *info);
376 #endif
377
378
379
380 /* in linux.c */
381
382 extern int show_nice_processes;
383
384 /* in cairo.c */
385
386 extern int do_it(void);
387
388 #endif