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;
141 #include "libmpdclient.h"
147 struct utsname uname_s;
153 /* memory information in kilobytes */
154 unsigned int mem, memmax, swap, swapmax;
155 unsigned int bufmem, buffers, cached;
158 unsigned int run_procs;
161 /* struct cpu_stat cpu_summed; what the hell is this? */
162 unsigned int cpu_count;
163 unsigned int cpu_avg_samples;
165 unsigned int net_avg_samples;
169 int new_mail_count, mail_count;
176 mpd_Connection *conn;
178 struct process *cpu[10];
179 struct process *memu[10];
180 unsigned long looped;
196 #include <X11/Xlib.h>
197 #include <X11/Xlib.h>
198 #include <X11/Xatom.h>
201 #include <X11/Xft/Xft.h>
204 #if defined(HAVE_XDBE) && defined(DOUBLE_BUFFER)
206 #include <X11/extensions/Xdbe.h>
209 #define ATOM(a) XInternAtom(display, #a, False)
211 struct conky_window {
216 XdbeBackBuffer back_buffer;
239 extern Display *display;
240 extern int display_width;
241 extern int display_height;
244 extern int workarea[4];
246 extern struct conky_window window;
249 #if defined OWN_WINDOW
250 void init_window(int use_own_window, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour);
252 void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour);
255 void set_transparent_background(Window win);
256 long get_x11_color(const char *);
262 /* struct that has all info */
263 struct information info;
266 double get_time(void);
267 FILE *open_file(const char *file, int *reported);
268 void variable_substitute(const char *s, char *dest, unsigned int n);
269 void format_seconds(char *buf, unsigned int n, long t);
270 void format_seconds_short(char *buf, unsigned int n, long t);
271 struct net_stat *get_net_stat(const char *dev);
275 int round_to_int(float f);
277 #define SET_NEED(a) need_mask |= 1 << (a)
278 extern unsigned long long need_mask;
280 extern double current_update_time, last_update_time;
282 extern int no_buffers;
284 /* system dependant (in linux.c) */
286 void update_diskio(void);
287 void prepare_update(void);
288 void update_uptime(void);
289 void update_meminfo(void);
290 void update_net_stats(void);
291 void update_wifi_stats(void);
292 void update_cpu_usage(void);
293 void update_total_processes(void);
294 void update_running_processes(void);
295 void update_i8k(void);
297 float get_freq_dynamic();
298 void update_load_average();
299 int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
301 double get_i2c_info(int *fd, int arg, char *devtype, char *type);
303 char *get_adt746x_cpu(void);
304 char *get_adt746x_fan(void);
305 unsigned int get_diskio(void);
307 int open_acpi_temperature(const char *name);
308 double get_acpi_temperature(int fd);
309 char *get_acpi_ac_adapter(void);
310 char *get_acpi_fan(void);
311 void get_battery_stuff(char *buf, unsigned int n, const char *bat);
314 struct process *next;
315 struct process *previous;
320 unsigned int user_time;
322 unsigned int kernel_time;
323 unsigned int previous_user_time;
324 unsigned int previous_kernel_time;
327 unsigned int time_stamp;
328 unsigned int counted;
329 unsigned int changed;
335 /* fs-stuff is possibly system dependant (in fs.c) */
337 void update_fs_stats(void);
338 struct fs_stat *prepare_fs_stat(const char *path);
339 void clear_fs_stats(void);
343 int mixer_init(const char *);
344 int mixer_get_avg(int);
345 int mixer_get_left(int);
346 int mixer_get_right(int);
350 extern char *current_mail_spool;
352 void update_mail_count();
357 extern char *seti_dir;
363 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
364 int apm_getinfo(int fd, apm_info_t aip);
365 char *get_apm_adapter(void);
366 char *get_apm_battery_life(void);
367 char *get_apm_battery_time(void);
377 typedef long long int64;
378 /* The info necessary to connect to mldonkey. login and password can be NULL. */
379 typedef struct mldonkey_config {
380 char *mldonkey_hostname;
382 char *mldonkey_login;
383 char *mldonkey_password;
386 /* The MLDonkey status returned */
387 typedef struct mldonkey_info {
388 int64 upload_counter;
389 int64 download_counter;
391 int64 shared_counter;
393 int tcp_download_rate;
395 int udp_download_rate;
396 int ndownloaded_files;
397 int ndownloading_files;
398 int nconnected_networks;
399 int connected_networks[1];
402 extern mldonkey_info mlinfo;
403 extern mldonkey_config mlconfig;
405 int get_mldonkey_status(mldonkey_config * config, mldonkey_info * info);
410 /* nothing to see here */
414 extern int do_it(void);