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>
23 #include <sys/param.h>
24 #if defined(__FreeBSD__)
25 #include <sys/mount.h>
26 #include <sys/ucred.h>
29 #endif /* __FreeBSD__ */
31 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
32 #include <machine/apm_bios.h>
33 #endif /* __FreeBSD__ */
36 #include "audacious.h"
40 #include <xmmsclient/xmmsclient.h>
43 #include "timed_thread.h"
50 #define TEXT_BUFFER_SIZE 1280
51 #define P_MAX_SIZE ((TEXT_BUFFER_SIZE * 4) - 2)
53 /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
54 #define MAX_SPECIALS_DEFAULT 512
56 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
57 #define MAX_USER_TEXT_DEFAULT 16384
59 #include <sys/socket.h>
61 #define ERR(s, varargs...) \
62 fprintf(stderr, "Conky: " s "\n", ##varargs)
65 #define CRIT_ERR(s, varargs...) \
66 { fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
73 char *left_fan_status;
74 char *right_fan_status;
81 struct i8k_struct i8k;
86 long long last_read_recv, last_read_trans;
87 long long recv, trans;
88 double recv_speed, trans_speed;
91 double net_rec[15], net_trans[15];
94 unsigned int diskio_value;
103 struct mail_s { // for imap and pop3
104 unsigned long unseen;
105 unsigned long messages;
117 timed_thread *p_timed_thread;
121 unsigned int user, nice, system, idle, iowait, irq, softirq;
172 audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */
173 timed_thread *p_timed_thread;
189 #ifdef TCP_PORT_MONITOR
190 #include "libtcp-portmon.h"
191 #define MIN_PORT_MONITORS_DEFAULT 16
192 #define MIN_PORT_MONITOR_CONNECTIONS_DEFAULT 256
217 #ifdef TCP_PORT_MONITOR
218 INFO_TCP_PORT_MONITOR = 19,
233 #include "libmpdclient.h"
236 volatile int g_signal_pending;
241 struct utsname uname_s;
247 /* memory information in kilobytes */
248 unsigned long long mem, memmax, swap, swapmax;
249 unsigned long long bufmem, buffers, cached;
251 unsigned short procs;
252 unsigned short run_procs;
255 /* struct cpu_stat cpu_summed; what the hell is this? */
256 unsigned int cpu_count;
257 unsigned int cpu_avg_samples;
259 unsigned int net_avg_samples;
263 int new_mail_count, mail_count;
268 mpd_Connection *conn;
271 struct xmms2_s xmms2;
272 int xmms2_conn_state;
273 xmms_socket_t xmms2_fd;
275 xmmsc_connection_t *xmms2_conn;
278 struct audacious_s audacious;
283 struct process *cpu[10];
284 struct process *memu[10];
285 struct process *first_process;
286 unsigned long looped;
287 #ifdef TCP_PORT_MONITOR
288 tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
290 short kflags; /* kernel settings, see enum KFLAG */
294 KFLAG_IS_LONGSTAT = 0x01, /* set to true if kernel uses "long" format for /proc/stats */
295 KFLAG_PROC_IS_THREADS=0x02 /* set to true if kernel shows # of threads for the proc value in sysinfo() call */
296 /* KFLAG_NEXT_ONE=0x04 bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
299 #define KFLAG_SETON(a) info.kflags |= a
300 #define KFLAG_SETOFF(a) info.kflags &= (~a)
301 #define KFLAG_FLIP(a) info.kflags ^= a
302 #define KFLAG_ISSET(a) info.kflags & a
312 char tmpstring1[TEXT_BUFFER_SIZE];
313 char tmpstring2[TEXT_BUFFER_SIZE];
318 #include <X11/Xlib.h>
319 #include <X11/Xlib.h>
320 #include <X11/Xatom.h>
323 #include <X11/Xft/Xft.h>
327 #include <X11/extensions/Xdbe.h>
330 #define ATOM(a) XInternAtom(display, #a, False)
340 HINT_UNDECORATED = 0,
347 #define SET_HINT(mask,hint) (mask |= (1<<hint))
348 #define TEST_HINT(mask,hint) (mask & (1<<hint))
350 struct conky_window {
351 Window root,window,desktop;
355 XdbeBackBuffer back_buffer;
364 char wm_class_name[256];
381 extern Display *display;
382 extern int display_width;
383 extern int display_height;
386 extern int workarea[4];
388 extern struct conky_window window;
391 void init_window(int use_own_window, int width, int height, int set_trans, int back_colour, char * nodename,
392 char **argv, int argc);
394 void set_transparent_background(Window win);
395 long get_x11_color(const char *);
401 /* struct that has all info */
402 struct information info;
404 void signal_handler(int);
405 void reload_config(void);
409 double get_time(void);
410 FILE *open_file(const char *file, int *reported);
411 void variable_substitute(const char *s, char *dest, unsigned int n);
412 void format_seconds(char *buf, unsigned int n, long t);
413 void format_seconds_short(char *buf, unsigned int n, long t);
414 struct net_stat *get_net_stat(const char *dev);
418 int round_to_int(float f);
420 #define SET_NEED(a) need_mask |= 1 << (a)
421 extern unsigned long long need_mask;
423 extern double current_update_time, last_update_time;
425 extern int no_buffers;
427 /* system dependant (in linux.c) */
429 void update_diskio(void);
430 void prepare_update(void);
431 void update_uptime(void);
432 void update_meminfo(void);
433 void update_net_stats(void);
434 void update_wifi_stats(void);
435 void update_cpu_usage(void);
436 void update_total_processes(void);
437 void update_running_processes(void);
438 void update_i8k(void);
439 char get_freq( char *, size_t, char *, int, unsigned int );
440 void get_freq_dynamic( char *, size_t, char *, int );
441 char get_voltage(char *, size_t, char *, int, unsigned int ); /* ptarjan */
442 void update_load_average();
443 int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
445 double get_i2c_info(int *fd, int arg, char *devtype, char *type);
447 void get_adt746x_cpu( char *, size_t );
448 void get_adt746x_fan( char *, size_t );
449 unsigned int get_diskio(void);
451 int open_acpi_temperature(const char *name);
452 double get_acpi_temperature(int fd);
453 void get_acpi_ac_adapter( char *, size_t );
454 void get_acpi_fan( char *, size_t );
455 void get_battery_stuff(char *buf, unsigned int n, const char *bat);
456 void get_ibm_acpi_fan(char *buf, size_t client_buffer_size);
457 void get_ibm_acpi_temps(void);
458 void get_ibm_acpi_volume(char *buf, size_t client_buffer_size);
459 void get_ibm_acpi_brightness(char *buf, size_t client_buffer_size);
460 void get_cpu_count();
462 struct ibm_acpi_struct {
463 unsigned int temps[8];
466 struct ibm_acpi_struct ibm_acpi;
468 enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME};
469 void get_powerbook_batt_info(char*, size_t, int);
472 struct process *next;
473 struct process *previous;
478 unsigned long user_time;
480 unsigned long kernel_time;
481 unsigned long previous_user_time;
482 unsigned long previous_kernel_time;
485 unsigned int time_stamp;
486 unsigned int counted;
487 unsigned int changed;
492 void free_all_processes();
493 struct process *get_first_process();
495 /* fs-stuff is possibly system dependant (in fs.c) */
497 void update_fs_stats(void);
498 struct fs_stat *prepare_fs_stat(const char *path);
499 void clear_fs_stats(void);
503 int mixer_init(const char *);
504 int mixer_get_avg(int);
505 int mixer_get_left(int);
506 int mixer_get_right(int);
510 extern char *current_mail_spool;
512 void update_mail_count();
515 #if defined(__FreeBSD__)
519 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
520 int apm_getinfo(int fd, apm_info_t aip);
521 char *get_apm_adapter(void);
522 char *get_apm_battery_life(void);
523 char *get_apm_battery_time(void);
538 int scan_hddtemp(const char *arg, char **dev, char **addr, int *port);
539 char *get_hddtemp_info(char *dev, char *addr, int port, char *unit);