2 * Conky, a system monitor, based on torsmo
4 * This program is licensed under BSD license, read COPYING
12 #if defined(HAS_MCHECK_H)
14 #endif /* HAS_MCHECK_H */
16 #include <sys/utsname.h>
24 #if defined(HAVE_CAIRO_H) && defined(HAVE_CAIRO_XLIB_H) && defined(WANT_CAIRO)
27 #include <X11/Xutil.h>
29 #include <cairo-xlib.h>
33 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
34 #include <machine/apm_bios.h>
35 #endif /* __FreeBSD__ */
42 #define TEXT_BUFFER_SIZE 1024
44 #include <sys/socket.h>
46 #define ERR(s, varargs...) \
47 fprintf(stderr, "Conky: " s "\n", ##varargs)
50 #define CRIT_ERR(s, varargs...) \
51 { fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
58 char *left_fan_status;
59 char *right_fan_status;
66 struct i8k_struct i8k;
71 long long last_read_recv, last_read_trans;
72 long long recv, trans;
73 double recv_speed, trans_speed;
76 double net_rec[15], net_trans[15];
79 unsigned int diskio_value;
89 unsigned int user, nice, system, idle, iowait, irq, softirq;
144 #include "libmpdclient.h"
150 struct utsname uname_s;
156 /* memory information in kilobytes */
157 unsigned int mem, memmax, swap, swapmax;
158 unsigned int bufmem, buffers, cached;
161 unsigned int run_procs;
164 /* struct cpu_stat cpu_summed; what the hell is this? */
165 unsigned int cpu_count;
166 unsigned int cpu_avg_samples;
168 unsigned int net_avg_samples;
172 int new_mail_count, mail_count;
179 mpd_Connection *conn;
181 struct process *cpu[10];
182 struct process *memu[10];
183 unsigned long looped;
199 #include <X11/Xlib.h>
200 #include <X11/Xlib.h>
201 #include <X11/Xatom.h>
204 #include <X11/Xft/Xft.h>
207 #if defined(HAVE_XDBE) && defined(DOUBLE_BUFFER)
209 #include <X11/extensions/Xdbe.h>
212 #define ATOM(a) XInternAtom(display, #a, False)
214 struct conky_window {
219 XdbeBackBuffer back_buffer;
242 extern Display *display;
243 extern int display_width;
244 extern int display_height;
247 extern int workarea[4];
249 extern struct conky_window window;
252 #if defined OWN_WINDOW
253 void init_window(int use_own_window, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour);
255 void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour);
258 void set_transparent_background(Window win);
259 long get_x11_color(const char *);
265 /* struct that has all info */
266 struct information info;
269 double get_time(void);
270 FILE *open_file(const char *file, int *reported);
271 void variable_substitute(const char *s, char *dest, unsigned int n);
272 void format_seconds(char *buf, unsigned int n, long t);
273 void format_seconds_short(char *buf, unsigned int n, long t);
274 struct net_stat *get_net_stat(const char *dev);
278 int round_to_int(float f);
280 #define SET_NEED(a) need_mask |= 1 << (a)
281 extern unsigned long long need_mask;
283 extern double current_update_time, last_update_time;
285 extern int no_buffers;
287 /* system dependant (in linux.c) */
289 void update_diskio(void);
290 void prepare_update(void);
291 void update_uptime(void);
292 void update_meminfo(void);
293 void update_net_stats(void);
294 void update_wifi_stats(void);
295 void update_cpu_usage(void);
296 void update_total_processes(void);
297 void update_running_processes(void);
298 void update_i8k(void);
300 float get_freq_dynamic();
301 void update_load_average();
302 int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
304 double get_i2c_info(int *fd, int arg, char *devtype, char *type);
306 char *get_adt746x_cpu(void);
307 char *get_adt746x_fan(void);
308 unsigned int get_diskio(void);
310 int open_acpi_temperature(const char *name);
311 double get_acpi_temperature(int fd);
312 char *get_acpi_ac_adapter(void);
313 char *get_acpi_fan(void);
314 void get_battery_stuff(char *buf, unsigned int n, const char *bat);
317 struct process *next;
318 struct process *previous;
323 unsigned int user_time;
325 unsigned int kernel_time;
326 unsigned int previous_user_time;
327 unsigned int previous_kernel_time;
330 unsigned int time_stamp;
331 unsigned int counted;
332 unsigned int changed;
338 /* fs-stuff is possibly system dependant (in fs.c) */
340 void update_fs_stats(void);
341 struct fs_stat *prepare_fs_stat(const char *path);
342 void clear_fs_stats(void);
346 int mixer_init(const char *);
347 int mixer_get_avg(int);
348 int mixer_get_left(int);
349 int mixer_get_right(int);
353 extern char *current_mail_spool;
355 void update_mail_count();
360 extern char *seti_dir;
366 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
367 int apm_getinfo(int fd, apm_info_t aip);
368 char *get_apm_adapter(void);
369 char *get_apm_battery_life(void);
370 char *get_apm_battery_time(void);
380 typedef long long int64;
381 /* The info necessary to connect to mldonkey. login and password can be NULL. */
382 typedef struct mldonkey_config {
383 char *mldonkey_hostname;
385 char *mldonkey_login;
386 char *mldonkey_password;
389 /* The MLDonkey status returned */
390 typedef struct mldonkey_info {
391 int64 upload_counter;
392 int64 download_counter;
394 int64 shared_counter;
396 int tcp_download_rate;
398 int udp_download_rate;
399 int ndownloaded_files;
400 int ndownloading_files;
401 int nconnected_networks;
402 int connected_networks[1];
405 extern mldonkey_info mlinfo;
406 extern mldonkey_config mlconfig;
408 int get_mldonkey_status(mldonkey_config * config, mldonkey_info * info);
413 /* nothing to see here */
417 extern int do_it(void);