/* * Conky, a system monitor, based on torsmo * * This program is licensed under BSD license, read COPYING * * $Id$ */ #ifndef _conky_h_ #define _conky_h_ #if defined(HAS_MCHECK_H) #include #endif /* HAS_MCHECK_H */ #include "config.h" #include #include #include #include #include #include #include #include #if defined(__FreeBSD__) #include #include #include #include #endif /* __FreeBSD__ */ #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__)) #include #endif /* __FreeBSD__ */ #if defined(__OpenBSD__) #include #include #include #endif /* __OpenBSD__ */ #ifdef AUDACIOUS #include "audacious.h" #endif #ifdef XMMS2 #include #endif #include "mboxscan.h" #include "timed_thread.h" #define TOP_CPU 1 #define TOP_NAME 2 #define TOP_PID 3 #define TOP_MEM 4 #define TEXT_BUFFER_SIZE 1280 #define P_MAX_SIZE ((TEXT_BUFFER_SIZE * 4) - 2) extern unsigned int text_buffer_size; /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */ #define MAX_SPECIALS_DEFAULT 512 /* maximum size of config TEXT buffer, i.e. below TEXT line. */ #define MAX_USER_TEXT_DEFAULT 16384 #include #define ERR(s, varargs...) \ fprintf(stderr, "Conky: " s "\n", ##varargs) /* critical error */ #define CRIT_ERR(s, varargs...) \ { fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); } struct i8k_struct { char *version; char *bios; char *serial; char *cpu_temp; char *left_fan_status; char *right_fan_status; char *left_fan_rpm; char *right_fan_rpm; char *ac_status; char *buttons_status; }; struct i8k_struct i8k; struct net_stat { const char *dev; int up; long long last_read_recv, last_read_trans; long long recv, trans; double recv_speed, trans_speed; struct sockaddr addr; int linkstatus; double net_rec[15], net_trans[15]; }; unsigned int diskio_value; unsigned int diskio_read_value; unsigned int diskio_write_value; struct fs_stat { char *path; long long size; long long avail; long long free; }; struct mail_s { // for imap and pop3 unsigned long unseen; unsigned long messages; unsigned long used; unsigned long quota; unsigned long port; float interval; double last_update; char host[128]; char user[128]; char pass[128]; char command[1024]; char folder[128]; char secure; timed_thread *p_timed_thread; } mail; /*struct cpu_stat { unsigned int user, nice, system, idle, iowait, irq, softirq; int cpu_avg_samples; };*/ #ifdef MPD struct mpd_s { char *title; char *artist; char *album; char *status; char *random; char *repeat; char *track; char *name; char *file; int volume; unsigned int port; char host[128]; char password[128]; float progress; int bitrate; int length; int elapsed; }; #endif #ifdef XMMS2 struct xmms2_s { char* artist; char* album; char* title; char* genre; char* comment; char* decoder; char* transport; char* url; char* date; int tracknr; int bitrate; unsigned int id; int duration; int elapsed; float size; float progress; char* status; }; #endif #ifdef AUDACIOUS struct audacious_s { audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */ int max_title_len; /* e.g. ${audacious_title 50} */ timed_thread *p_timed_thread; }; #endif #ifdef BMPX void update_bmpx(); struct bmpx_s { char *title; char *artist; char *album; char *uri; int bitrate; int track; }; #endif void update_entropy(); struct entropy_s { unsigned int entropy_avail; unsigned int poolsize; }; #ifdef TCP_PORT_MONITOR #include "libtcp-portmon.h" #define MAX_PORT_MONITOR_CONNECTIONS_DEFAULT 256 #endif enum { INFO_CPU = 0, INFO_MAIL = 1, INFO_MEM = 2, INFO_NET = 3, INFO_PROCS = 4, INFO_RUN_PROCS = 5, INFO_UPTIME = 6, INFO_BUFFERS = 7, INFO_FS = 8, INFO_I2C = 9, INFO_MIXER = 10, INFO_LOADAVG = 11, INFO_UNAME = 12, INFO_FREQ = 13, #ifdef MPD INFO_MPD = 14, #endif INFO_TOP = 15, INFO_WIFI = 16, INFO_DISKIO = 17, INFO_I8K = 18, #ifdef TCP_PORT_MONITOR INFO_TCP_PORT_MONITOR = 19, #endif #ifdef AUDACIOUS INFO_AUDACIOUS = 20, #endif #ifdef BMPX INFO_BMPX = 21, #endif #ifdef XMMS2 INFO_XMMS2 = 22, #endif INFO_ENTROPY = 23, }; /* get_battery_stuff() item selector */ enum { BATTERY_STATUS, BATTERY_TIME }; #ifdef MPD #include "libmpdclient.h" #endif /* Update interval */ double update_interval; volatile int g_signal_pending; struct information { unsigned int mask; struct utsname uname_s; char freq[10]; double uptime; /* memory information in kilobytes */ unsigned long long mem, memmax, swap, swapmax; unsigned long long bufmem, buffers, cached; unsigned short procs; unsigned short run_procs; float *cpu_usage; /* struct cpu_stat cpu_summed; what the hell is this? */ unsigned int cpu_count; unsigned int cpu_avg_samples; unsigned int net_avg_samples; float loadavg[3]; int new_mail_count, mail_count; struct mail_s* mail; int mail_running; #ifdef MPD struct mpd_s mpd; mpd_Connection *conn; #endif #ifdef XMMS2 struct xmms2_s xmms2; int xmms2_conn_state; xmms_socket_t xmms2_fd; fd_set xmms2_fdset; xmmsc_connection_t *xmms2_conn; #endif #ifdef AUDACIOUS struct audacious_s audacious; #endif #ifdef BMPX struct bmpx_s bmpx; #endif struct process *cpu[10]; struct process *memu[10]; struct process *first_process; unsigned long looped; #ifdef TCP_PORT_MONITOR tcp_port_monitor_collection_t * p_tcp_port_monitor_collection; #endif short kflags; /* kernel settings, see enum KFLAG */ struct entropy_s entropy; }; enum { KFLAG_IS_LONGSTAT = 0x01, /* set to true if kernel uses "long" format for /proc/stats */ KFLAG_PROC_IS_THREADS=0x02 /* set to true if kernel shows # of threads for the proc value in sysinfo() call */ /* KFLAG_NEXT_ONE=0x04 bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */ }; #define KFLAG_SETON(a) info.kflags |= a #define KFLAG_SETOFF(a) info.kflags &= (~a) #define KFLAG_FLIP(a) info.kflags ^= a #define KFLAG_ISSET(a) info.kflags & a int out_to_console; int top_cpu; int top_mem; int use_spacer; char tmpstring1[TEXT_BUFFER_SIZE]; char tmpstring2[TEXT_BUFFER_SIZE]; #ifdef X11 /* in x11.c */ #include #include #include #ifdef XFT #include #endif #ifdef HAVE_XDBE #include #endif #define ATOM(a) XInternAtom(display, #a, False) #ifdef OWN_WINDOW enum _window_type { TYPE_NORMAL = 0, TYPE_DESKTOP, TYPE_OVERRIDE }; enum _window_hints { HINT_UNDECORATED = 0, HINT_BELOW, HINT_ABOVE, HINT_STICKY, HINT_SKIP_TASKBAR, HINT_SKIP_PAGER }; #define SET_HINT(mask,hint) (mask |= (1<