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>
22 #if defined(__FreeBSD__)
23 #include <sys/param.h>
24 #include <sys/mount.h>
25 #include <sys/ucred.h>
26 #endif /* __FreeBSD__ */
29 #if defined(HAVE_CAIRO_H) && defined(HAVE_CAIRO_XLIB_H) && defined(WANT_CAIRO)
32 #include <X11/Xutil.h>
34 #include <cairo-xlib.h>
38 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
39 #include <machine/apm_bios.h>
40 #endif /* __FreeBSD__ */
47 #define TEXT_BUFFER_SIZE 1024
49 #include <sys/socket.h>
51 #define ERR(s, varargs...) \
52 fprintf(stderr, "Conky: " s "\n", ##varargs)
55 #define CRIT_ERR(s, varargs...) \
56 { fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
63 char *left_fan_status;
64 char *right_fan_status;
71 struct i8k_struct i8k;
76 long long last_read_recv, last_read_trans;
77 long long recv, trans;
78 double recv_speed, trans_speed;
81 double net_rec[15], net_trans[15];
84 unsigned int diskio_value;
93 unsigned int user, nice, system, idle, iowait, irq, softirq;
116 #ifdef TCP_PORT_MONITOR
117 #include "libtcp-portmon.h"
118 #define MIN_PORT_MONITORS_DEFAULT 16
119 #define MIN_PORT_MONITOR_CONNECTIONS_DEFAULT 256
150 #ifdef TCP_PORT_MONITOR
151 INFO_TCP_PORT_MONITOR = 22,
157 #include "libmpdclient.h"
160 volatile int g_signal_pending;
165 struct utsname uname_s;
171 /* memory information in kilobytes */
172 unsigned long mem, memmax, swap, swapmax;
173 unsigned long bufmem, buffers, cached;
176 unsigned int run_procs;
179 /* struct cpu_stat cpu_summed; what the hell is this? */
180 unsigned int cpu_count;
181 unsigned int cpu_avg_samples;
183 unsigned int net_avg_samples;
187 int new_mail_count, mail_count;
194 mpd_Connection *conn;
196 struct process *cpu[10];
197 struct process *memu[10];
198 struct process *first_process;
199 unsigned long looped;
200 #ifdef TCP_PORT_MONITOR
201 tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
212 char tmpstring1[TEXT_BUFFER_SIZE];
213 char tmpstring2[TEXT_BUFFER_SIZE];
218 #include <X11/Xlib.h>
219 #include <X11/Xlib.h>
220 #include <X11/Xatom.h>
223 #include <X11/Xft/Xft.h>
226 #if defined(HAVE_XDBE) && defined(DOUBLE_BUFFER)
228 #include <X11/extensions/Xdbe.h>
231 #define ATOM(a) XInternAtom(display, #a, False)
233 struct conky_window {
238 XdbeBackBuffer back_buffer;
261 extern Display *display;
262 extern int display_width;
263 extern int display_height;
266 extern int workarea[4];
268 extern struct conky_window window;
271 #if defined OWN_WINDOW
272 void init_window(int use_own_window, char* wm_class_name, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour, char * nodename);
274 void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour, char * nodename);
277 void set_transparent_background(Window win);
278 long get_x11_color(const char *);
284 /* struct that has all info */
285 struct information info;
287 void signal_handler(int);
288 void reload_config(void);
292 double get_time(void);
293 FILE *open_file(const char *file, int *reported);
294 void variable_substitute(const char *s, char *dest, unsigned int n);
295 void format_seconds(char *buf, unsigned int n, long t);
296 void format_seconds_short(char *buf, unsigned int n, long t);
297 struct net_stat *get_net_stat(const char *dev);
301 int round_to_int(float f);
303 #define SET_NEED(a) need_mask |= 1 << (a)
304 extern unsigned long long need_mask;
306 extern double current_update_time, last_update_time;
308 extern int no_buffers;
310 /* system dependant (in linux.c) */
312 void update_diskio(void);
313 void prepare_update(void);
314 void update_uptime(void);
315 void update_meminfo(void);
316 void update_net_stats(void);
317 void update_wifi_stats(void);
318 void update_cpu_usage(void);
319 void update_total_processes(void);
320 void update_running_processes(void);
321 void update_i8k(void);
322 void get_freq( char *, size_t, char *, int ); /* pk */
323 void get_freq_dynamic( char *, size_t, char *, int ); /* pk */
324 void update_load_average();
325 int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
327 double get_i2c_info(int *fd, int arg, char *devtype, char *type);
329 void get_adt746x_cpu( char *, size_t ); /* pk */
330 void get_adt746x_fan( char *, size_t ); /* pk */
331 unsigned int get_diskio(void);
333 int open_acpi_temperature(const char *name);
334 double get_acpi_temperature(int fd);
335 void get_acpi_ac_adapter( char *, size_t ); /* pk */
336 void get_acpi_fan( char *, size_t ); /* pk */
337 void get_battery_stuff(char *buf, unsigned int n, const char *bat);
340 struct process *next;
341 struct process *previous;
346 unsigned long user_time;
348 unsigned long kernel_time;
349 unsigned long previous_user_time;
350 unsigned long previous_kernel_time;
353 unsigned int time_stamp;
354 unsigned int counted;
355 unsigned int changed;
360 void free_all_processes();
361 struct process *get_first_process();
363 /* fs-stuff is possibly system dependant (in fs.c) */
365 void update_fs_stats(void);
366 struct fs_stat *prepare_fs_stat(const char *path);
367 void clear_fs_stats(void);
371 int mixer_init(const char *);
372 int mixer_get_avg(int);
373 int mixer_get_left(int);
374 int mixer_get_right(int);
378 extern char *current_mail_spool;
380 void update_mail_count();
385 extern char *seti_dir;
391 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
392 int apm_getinfo(int fd, apm_info_t aip);
393 char *get_apm_adapter(void);
394 char *get_apm_battery_life(void);
395 char *get_apm_battery_time(void);
405 typedef long long int64;
406 /* The info necessary to connect to mldonkey. login and password can be NULL. */
407 typedef struct mldonkey_config {
408 char *mldonkey_hostname;
410 char *mldonkey_login;
411 char *mldonkey_password;
414 /* The MLDonkey status returned */
415 typedef struct mldonkey_info {
416 int64 upload_counter;
417 int64 download_counter;
419 int64 shared_counter;
421 int tcp_download_rate;
423 int udp_download_rate;
424 int ndownloaded_files;
425 int ndownloading_files;
426 int nconnected_networks;
427 int connected_networks[1];
430 extern mldonkey_info mlinfo;
431 extern mldonkey_config mlconfig;
433 int get_mldonkey_status(mldonkey_config * config, mldonkey_info * info);
438 /* nothing to see here */
442 extern int do_it(void);