#include <unistd.h>
#include <string.h>
#include <errno.h>
-#include <pthread.h>
+#include <termios.h>
#include <string.h>
#include <limits.h>
#if HAVE_DIRENT_H
#include <sys/time.h>
#ifdef X11
#include <X11/Xutil.h>
+#include <X11/extensions/Xdamage.h>
+#ifdef IMLIB2
+#include <Imlib2.h>
+#endif /* IMLIB2 */
#endif /* X11 */
#include <sys/types.h>
#include <sys/stat.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+
+#ifdef HAVE_ICONV
+#include <iconv.h>
+#endif
+
+#include "build.h"
#define CONFIG_FILE "$HOME/.conkyrc"
#define MAIL_FILE "$MAIL"
#ifdef X11
+/*
+ * text size
+ */
+
+static int text_start_x, text_start_y; /* text start position in window */
+static int text_width, text_height;
+
/* alignments */
enum alignment {
TOP_LEFT = 1,
#ifdef XFT
-#define font_height() use_xft ? (fonts[selected_font].xftfont->ascent + fonts[selected_font].xftfont->descent) : \
-(fonts[selected_font].font->max_bounds.ascent + fonts[selected_font].font->max_bounds.descent)
-#define font_ascent() use_xft ? fonts[selected_font].xftfont->ascent : fonts[selected_font].font->max_bounds.ascent
-#define font_descent() use_xft ? fonts[selected_font].xftfont->descent : fonts[selected_font].font->max_bounds.descent
+#define font_height() (use_xft ? (fonts[selected_font].xftfont->ascent + fonts[selected_font].xftfont->descent) : \
+(fonts[selected_font].font->max_bounds.ascent + fonts[selected_font].font->max_bounds.descent))
+#define font_ascent() (use_xft ? fonts[selected_font].xftfont->ascent : fonts[selected_font].font->max_bounds.ascent)
+#define font_descent() (use_xft ? fonts[selected_font].xftfont->descent : fonts[selected_font].font->max_bounds.descent)
#else
static void set_font();
+static void print_version()
+{
+ printf("Conky %s compiled %s for %s\n",
+ VERSION, BUILD_DATE, BUILD_ARCH);
+
+ printf(
+ "\nCompiled in features:\n\n"
+#ifdef X11
+ " X11:\n"
+# ifdef XFT
+ " * xft\n"
+# endif /* XFT */
+# ifdef HAVE_XDAMAGE
+ " * Xdamage extension\n"
+# endif /* HAVE_XDAMAGE */
+# ifdef HAVE_XDBE
+ " * Xdbe extension (double buffer)\n"
+# endif /* HAVE_XDBE */
+#endif /* X11 */
+ "\n Music detection:\n"
+#ifdef XMMS
+ " * xmms\n"
+#endif /* XMMS */
+#ifdef BMP
+ " * bmp\n"
+#endif /* BMP */
+#ifdef AUDACIOUS
+ " * audacious\n"
+#endif /* AUDACIOUS */
+#ifdef INFOPIPE
+ " * infopipe\n"
+#endif /* INFOPIPE */
+#ifdef BMPX
+ " * bmpx\n"
+#endif /* BMPX */
+#ifdef XMMS2
+ " * xmms2\n"
+#endif /* XMMS2 */
+#ifdef MPD
+ " * mpd\n"
+#endif /* MPD */
+ "\n General features:\n"
+#ifdef TCP_PORT_MONITOR
+ " * portmon\n"
+#endif /* TCP_PORT_MONITOR */
+#ifdef MLDONKEY
+ " * mldonkey\n"
+#endif /* MLDONKEY */
+#ifdef HDDTEMP
+ " * hddtemp\n"
+#endif /* HDDTEMP */
+#ifdef SETI
+ " * seti\n"
+#endif /* SETI*/
+ "\n");
+
+ exit(0);
+}
+
int addfont(const char *data_in)
{
if (font_count > MAX_FONTS) {
static void load_fonts()
{
int i;
- for (i=0;i<=font_count;i++) {
+ for (i=0; i <= font_count; i++) {
#ifdef XFT
/* load Xft font */
if (use_xft) {
#ifdef OWN_WINDOW
static int own_window = 0;
static int background_colour = 0;
-static char wm_class_name[256];
/* fixed size/pos is set if wm/user changes them */
static int fixed_size = 0, fixed_pos = 0;
#endif
static int minimum_width, minimum_height;
static int maximum_width;
+
+
+#ifdef HAVE_ICONV
+#define CODEPAGE_LENGTH 20
+long iconv_selected;
+long iconv_count;
+char iconv_converting;
+static iconv_t **iconv_cd = 0;
+
+int register_iconv(iconv_t *new_iconv)
+{
+ if (iconv_cd) {
+ iconv_cd = realloc(iconv, sizeof(iconv_t *) * (iconv_count + 1));
+ } else {
+ iconv_cd = malloc(sizeof(iconv_t *));
+ }
+ if (!iconv_cd) {
+ CRIT_ERR("Out of memory");
+ }
+ iconv_cd[iconv_count] = malloc(sizeof(iconv_t));
+ if (!iconv_cd[iconv_count]) {
+ CRIT_ERR("Out of memory");
+ }
+ memcpy(iconv_cd[iconv_count], new_iconv, sizeof(iconv_t));
+ iconv_count++;
+ return iconv_count;
+}
+
+void free_iconv(void)
+{
+ if (iconv_cd) {
+ long i;
+ for (i = iconv_count; i < 0; i++) {
+ if (iconv_cd[i]) {
+ free(iconv_cd[i]);
+ }
+ }
+ free(iconv_cd);
+ }
+ iconv_cd = 0;
+
+}
+
+#endif
+
/* UTF-8 */
int utf8_mode = 0;
" / $color${fs_free /}/${fs_size /} ${fs_bar 6 /}\n"
"${color grey}Networking:\n"
" Up:$color ${upspeed eth0} k/s${color grey} - Down:$color ${downspeed eth0} k/s\n"
- "${color grey}Temperatures:\n"
- " CPU:$color ${i2c temp 1}°C${color grey} - MB:$color ${i2c temp 2}°C\n"
"$hr\n"
#ifdef SETI
"${color grey}SETI@Home Statistics:\n"
"${color grey}MPD: $mpd_status $mpd_artist - $mpd_title from $mpd_album at $mpd_vol\n"
"Bitrate: $mpd_bitrate\n" "Progress: $mpd_bar\n"
#endif
+#ifdef XMMS2
+ "${color grey}XMMS2: $xmms2_status $xmms2_artist - $xmms2_title from $xmms2_album\n"
+ "Progress: $xmms2_bar\n"
+#endif
"${color grey}Name PID CPU% MEM%\n"
" ${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}\n"
" ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}\n"
"${tail /var/log/Xorg.0.log 3}";
static char *text = original_text;
+long text_lines;
static int total_updates;
OFFSET,
VOFFSET,
FONT,
+ GOTO,
+ TAB,
};
static struct special_t {
static struct special_t *new_special(char *buf, int t)
{
- if (special_count >= 128)
+ if (special_count >= 512)
CRIT_ERR("too many special things in text");
buf[0] = SPECIAL_CHAR;
if (args && sizeof(args) < 127) {
return strdup(args);
}
- else {
- ERR("font scan failed, lets hope it doesn't mess stuff up");
- }
return NULL;
}
#ifdef X11
static void new_font(char *buf, char * args) {
- struct special_t *s = new_special(buf, FONT);
- if (!s->font_added || strcmp(args, fonts[s->font_added].name)) {
+ if (args) {
+ struct special_t *s = new_special(buf, FONT);
+ if (!s->font_added || strcmp(args, fonts[s->font_added].name)) {
+ int tmp = selected_font;
+ selected_font = s->font_added = addfont(args);
+ load_fonts();
+ selected_font = tmp;
+ }
+ } else {
+ struct special_t *s = new_special(buf, FONT);
int tmp = selected_font;
- selected_font = s->font_added = addfont(args);
+ selected_font = s->font_added = 0;
load_fonts();
-// set_font();
selected_font = tmp;
}
}
if (graph->scaled) {
graph->graph_scale = 1;
}
- graph->graph[graph->graph_width - 1] = f; /* add new data */
- for (i = 0; i < graph->graph_width - 1; i++) { /* shift all the data by 1 */
- graph->graph[i] = graph->graph[i + 1];
+ graph->graph[0] = f; /* add new data */
+ for (i = graph->graph_width - 1; i > 0; i--) { /* shift all the data by 1 */
+ graph->graph[i] = graph->graph[i - 1];
if (graph->scaled && graph->graph[i] > graph->graph_scale) {
graph->graph_scale = graph->graph[i]; /* check if we need to update the scale */
}
s->width = w;
if (s->graph == NULL) {
if (s->width > 0 && s->width < MAX_GRAPH_DEPTH) {
- s->graph_width = s->width - 3; // subtract 3 for the box
+ s->graph_width = s->width/* - 2*/; // subtract 2 for the box
} else {
- s->graph_width = MAX_GRAPH_DEPTH - 3;
+ s->graph_width = MAX_GRAPH_DEPTH - 2;
}
s->graph = malloc(s->graph_width * sizeof(double));
memset(s->graph, 0, s->graph_width * sizeof(double));
s->scaled = 1;
}
/*if (s->width) {
- s->graph_width = s->width - 3; // subtract 3 for rectangle around
+ s->graph_width = s->width - 2; // subtract 2 for rectangle around
}*/
if (s->scaled) {
s->graph_scale = 1;
new_special(buf, ALIGNC)->arg = c;
}
+static inline void new_goto(char *buf, long c)
+{
+ new_special(buf, GOTO)->arg = c;
+}
+
+static inline void new_tab(char *buf, int a, int b) {
+ struct special_t *s = new_special(buf, TAB);
+ s->width = a;
+ s->arg = b;
+}
+
/* quite boring functions */
static inline void for_each_line(char *b, void (*f) (char *))
{
// Strange conditional due to possible overflows
if(a / 1024 / 1024 / 1024.0 > 1024.0){
- snprintf(buf, size, "%.2fT", (a / 1024 / 1024 / 1024) / 1024.0);
+ snprintf(buf, size, "%.2fTiB", (a / 1024 / 1024 / 1024) / 1024.0);
}
else if (a >= 1024 * 1024 * 1024) {
- snprintf(buf, size, "%.2fG", (a / 1024 / 1024) / 1024.0);
+ snprintf(buf, size, "%.2fGiB", (a / 1024 / 1024) / 1024.0);
}
else if (a >= 1024 * 1024) {
double m = (a / 1024) / 1024.0;
if (m >= 100.0)
- snprintf(buf, size, "%.0fM", m);
+ snprintf(buf, size, "%.0fMiB", m);
else
- snprintf(buf, size, "%.1fM", m);
+ snprintf(buf, size, "%.1fMiB", m);
} else if (a >= 1024)
- snprintf(buf, size, "%Ldk", a / (long long) 1024);
+ snprintf(buf, size, "%LdKiB", a / (long long) 1024);
else
- snprintf(buf, size, "%Ld", a);
+ snprintf(buf, size, "%LdB", a);
}
/* text handling */
OBJ_downspeedgraph,
OBJ_else,
OBJ_endif,
+ OBJ_image,
OBJ_exec,
OBJ_execi,
OBJ_texeci,
OBJ_fs_size,
OBJ_fs_used,
OBJ_fs_used_perc,
+ OBJ_goto,
+ OBJ_tab,
OBJ_hr,
OBJ_offset,
OBJ_voffset,
OBJ_i8k_right_fan_rpm,
OBJ_i8k_ac_status,
OBJ_i8k_buttons_status,
+ OBJ_ibm_fan,
+ OBJ_ibm_temps,
+ OBJ_ibm_volume,
+ OBJ_ibm_brightness,
+ OBJ_pb_battery,
+ OBJ_voltage_mv,
+ OBJ_voltage_v,
#endif /* __linux__ */
OBJ_if_existing,
OBJ_if_mounted,
OBJ_text,
OBJ_time,
OBJ_utime,
+ OBJ_tztime,
OBJ_totaldown,
OBJ_totalup,
OBJ_updates,
OBJ_upspeedgraph,
OBJ_uptime,
OBJ_uptime_short,
+ OBJ_imap,
+ OBJ_imap_messages,
+ OBJ_imap_unseen,
+ OBJ_pop3,
+ OBJ_pop3_unseen,
+ OBJ_pop3_used,
#if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
OBJ_apm_adapter,
OBJ_apm_battery_time,
OBJ_mpd_status,
OBJ_mpd_host,
OBJ_mpd_port,
+ OBJ_mpd_password,
OBJ_mpd_bar,
OBJ_mpd_elapsed,
OBJ_mpd_length,
OBJ_mpd_track,
+ OBJ_mpd_name,
+ OBJ_mpd_file,
OBJ_mpd_percent,
+ OBJ_mpd_smart,
+#endif
+#ifdef XMMS2
+ OBJ_xmms2_artist,
+ OBJ_xmms2_album,
+ OBJ_xmms2_title,
+ OBJ_xmms2_genre,
+ OBJ_xmms2_comment,
+ OBJ_xmms2_decoder,
+ OBJ_xmms2_transport,
+ OBJ_xmms2_url,
+ OBJ_xmms2_date,
+ OBJ_xmms2_tracknr,
+ OBJ_xmms2_bitrate,
+ OBJ_xmms2_id,
+ OBJ_xmms2_duration,
+ OBJ_xmms2_elapsed,
+ OBJ_xmms2_size,
+ OBJ_xmms2_percent,
+ OBJ_xmms2_status,
+ OBJ_xmms2_bar,
+ OBJ_xmms2_smart,
+#endif
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ OBJ_xmms_status,
+ OBJ_xmms_title,
+ OBJ_xmms_length,
+ OBJ_xmms_length_seconds,
+ OBJ_xmms_position,
+ OBJ_xmms_position_seconds,
+ OBJ_xmms_bitrate,
+ OBJ_xmms_frequency,
+ OBJ_xmms_channels,
+ OBJ_xmms_filename,
+ OBJ_xmms_playlist_length,
+ OBJ_xmms_playlist_position,
+ OBJ_xmms_bar,
#endif
#ifdef BMPX
OBJ_bmpx_title,
OBJ_bmpx_uri,
OBJ_bmpx_bitrate,
#endif
-#ifdef INFOPIPE
- OBJ_infopipe_protocol,
- OBJ_infopipe_version,
- OBJ_infopipe_status,
- OBJ_infopipe_playlist_tunes,
- OBJ_infopipe_playlist_currtune,
- OBJ_infopipe_usec_position,
- OBJ_infopipe_position,
- OBJ_infopipe_usec_time,
- OBJ_infopipe_time,
- OBJ_infopipe_bitrate,
- OBJ_infopipe_frequency,
- OBJ_infopipe_channels,
- OBJ_infopipe_title,
- OBJ_infopipe_file,
- OBJ_infopipe_bar,
-#endif
#ifdef TCP_PORT_MONITOR
OBJ_tcp_portmon,
#endif
+
+#ifdef HAVE_ICONV
+ OBJ_iconv_start,
+ OBJ_iconv_stop,
+#endif
+#ifdef HDDTEMP
+ OBJ_hddtemp,
+#endif
};
struct text_object {
int type;
int a, b;
+ long line;
unsigned int c, d, e;
float f;
+ char global_mode;
union {
char *s; /* some string */
int i; /* some integer */
long l; /* some other integer */
- struct net_stat *net;
+ unsigned int sensor;
+ struct net_stat *net;
struct fs_stat *fs;
unsigned char loadavg[3];
- //unsigned int diskio;
unsigned int cpu_index;
+ struct mail_s *mail;
+
+ struct {
+ char *tz; /* timezone variable */
+ char *fmt; /* time display formatting */
+ } tztime;
+
struct {
struct fs_stat *fs;
int w, h;
char *cmd;
char *buffer;
double data;
+ int pos;
+ struct thread_info_s thread_info;
} execi; /* 5 */
struct {
in_port_t port_range_end; /* ending port to monitor */
int item; /* enum value from libtcp-portmon.h, e.g. COUNT, REMOTEIP, etc. */
int connection_index; /* 0 to n-1 connections. */
- } tcp_port_monitor;
+ } tcp_port_monitor;
#endif
+ struct {
+ char *addr;
+ int port;
+ char *dev;
+ } hddtemp; /* 2 */
} data;
};
struct text_object_list {
- unsigned int text_object_count;
- struct text_object *text_objects;
+ unsigned int text_object_count;
+ struct text_object *text_objects;
};
static unsigned int text_object_count;
static struct text_object *text_objects;
static void generate_text_internal(char *p, int p_max_size, struct text_object *objs, unsigned int object_count, struct information *cur);
-pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
-
-void *threaded_exec( struct text_object *obj ) {
- char *p2 = obj->data.execi.buffer;
- FILE *fp = popen(obj->data.execi.cmd,"r");
- pthread_mutex_lock( &mutex1 );
- int n2 = fread(p2, 1, TEXT_BUFFER_SIZE, fp);
- (void) pclose(fp);
- p2[n2] = '\0';
- if (n2 && p2[n2 - 1] == '\n')
- p2[n2 - 1] = '\0';
-
- while (*p2) {
- if (*p2 == '\001')
- *p2 = ' ';
- p2++;
- }
- pthread_mutex_unlock( &mutex1 );
- return NULL;
-}
+#define MAX_THREADS 512 // sure whatever
+typedef struct thread_info_s *thread_info;
+static thread_info thread_list[MAX_THREADS];
+static int thread_count = 0;
+static int threads_runnable = 1;
-static struct text_object *new_text_object_internal()
+int register_thread(struct thread_info_s *new_thread)
{
- struct text_object *obj = malloc(sizeof(struct text_object));
- memset(obj, 0, sizeof(struct text_object));
- return obj;
+ if (thread_count >= MAX_THREADS) {
+ CRIT_ERR("Uh oh, tried to register too many threads");
+ } else {
+ thread_list[thread_count] = new_thread;
+ thread_count++;
+ // may as well fix the mutex for them as well
+ pthread_mutex_init(&(new_thread->mutex), NULL);
+ }
+ return thread_count - 1;
}
-#ifdef MLDONKEY
-void ml_cleanup()
-{
- if (mlconfig.mldonkey_hostname) {
- free(mlconfig.mldonkey_hostname);
- mlconfig.mldonkey_hostname = NULL;
+#define MAXDATASIZE 1000
+#define POP3 1
+#define IMAP 2
+
+struct mail_s* parse_mail_args(char type, const char *arg) {
+ struct mail_s *mail;
+ mail = malloc(sizeof(struct mail_s));
+ memset(mail, 0, sizeof(struct mail_s));
+ char *tmp;
+ if (sscanf(arg, "%128s %128s %128s", mail->host, mail->user, mail->pass) != 3) {
+ if (type == POP3) {
+ ERR("Scanning IMAP args failed");
+ } else if (type == IMAP) {
+ ERR("Scanning POP3 args failed");
+ }
+ }
+ // see if password needs prompting
+ if (mail->pass[0] == '*' && mail->pass[1] == '\0') {
+ int fp = fileno(stdin);
+ struct termios term;
+ tcgetattr(fp, &term);
+ term.c_lflag &= ~ECHO;
+ tcsetattr(fp, TCSANOW, &term);
+ printf("Enter mailbox password (%s@%s): ", mail->user, mail->host);
+ scanf("%128s", mail->pass);
+ printf("\n");
+ term.c_lflag |= ECHO;
+ tcsetattr(fp, TCSANOW, &term);
+ }
+ // now we check for optional args
+ tmp = strstr(arg, "-i ");
+ if (tmp) {
+ tmp += 3;
+ sscanf(tmp, "%f", &mail->interval);
+ } else {
+ mail->interval = 300; // 5 minutes
+ }
+ tmp = strstr(arg, "-p ");
+ if (tmp) {
+ tmp += 3;
+ sscanf(tmp, "%lu", &mail->port);
+ } else {
+ if (type == POP3) {
+ mail->port = 110; // default pop3 port
+ } else if (type == IMAP) {
+ mail->port = 143; // default imap port
+ }
}
+ if (type == IMAP) {
+ tmp = strstr(arg, "-f ");
+ if (tmp) {
+ tmp += 3;
+ sscanf(tmp, "%s", mail->folder);
+ } else {
+ strncpy(mail->folder, "INBOX", 128); // default imap inbox
+ }
+ }
+ tmp = strstr(arg, "-e ");
+ if (tmp) {
+ tmp += 3;
+ int len = 1024;
+ if (tmp[0] == '\'') {
+ len = strstr(tmp+1, "'") - tmp - 1;
+ if (len > 1024) {
+ len = 1024;
+ }
+ }
+ strncpy(mail->command, tmp+1, len);
+ } else {
+ mail->command[0] = '\0';
+ }
+ mail->pos = -1;
+ return mail;
}
-#endif
-static void free_text_objects(unsigned int count, struct text_object *objs)
-{
- unsigned int i;
- for (i = 0; i < count; i++) {
- switch (objs[i].type) {
- case OBJ_acpitemp:
- close(objs[i].data.i);
- break;
- case OBJ_acpitempf:
- close(objs[i].data.i);
- break;
- case OBJ_i2c:
- close(objs[i].data.i2c.fd);
- break;
- case OBJ_time:
- free(objs[i].data.s);
- break;
- case OBJ_utime:
- case OBJ_if_existing:
- case OBJ_if_mounted:
- case OBJ_if_running:
- free(objs[i].data.ifblock.s);
- break;
- case OBJ_tail:
- free(objs[i].data.tail.logfile);
- free(objs[i].data.tail.buffer);
- break;
- case OBJ_text: case OBJ_font:
- free(objs[i].data.s);
- break;
- case OBJ_exec:
- free(objs[i].data.s);
- break;
- case OBJ_execbar:
- free(objs[i].data.s);
- break;
- case OBJ_execgraph:
- free(objs[i].data.s);
- break;
-/* case OBJ_execibar:
- free(objs[i].data.s);
- break;
- case OBJ_execigraph:
- free(objs[i].data.s);
- break;*/
-#ifdef MPD
- case OBJ_mpd_title:
- case OBJ_mpd_artist:
- case OBJ_mpd_album:
- case OBJ_mpd_random:
- case OBJ_mpd_repeat:
- case OBJ_mpd_track:
- case OBJ_mpd_status:
- case OBJ_mpd_host:
-#endif
-#ifdef BMPX
- case OBJ_bmpx_title:
- case OBJ_bmpx_artist:
- case OBJ_bmpx_album:
- case OBJ_bmpx_track:
- case OBJ_bmpx_uri:
- case OBJ_bmpx_bitrate:
-#endif
- case OBJ_pre_exec:
- case OBJ_battery:
- free(objs[i].data.s);
- break;
+void *imap_thread(struct mail_s* mail)
+{ // pthreads are really beginning to piss me off
+ double update_time;
+ int run_code = threads_runnable;
+ update_time = get_time();
+ int sockfd, numbytes;
+ char recvbuf[MAXDATASIZE];
+ char sendbuf[MAXDATASIZE];
+ char *reply;
+ int fail = 0;
+ unsigned int old_unseen = UINT_MAX;
+ unsigned int old_messages = UINT_MAX;
+ struct hostent *he;
+ struct sockaddr_in their_addr; // connector's address information
+ if ((he = gethostbyname(mail->host)) == NULL) { // get the host info
+ herror("gethostbyname");
+ exit(1);
+ }
+ while (threads_runnable == run_code && fail < 5) {
+ if (fail > 0) {
+ ERR("Trying IMAP connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
+ sleep((int)mail->interval);
+ }
+ update_time = get_time();
+ if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
+ perror("socket");
+ fail++;
+ continue;
+ }
- case OBJ_execi:
- free(objs[i].data.execi.cmd);
- free(objs[i].data.execi.buffer);
- break;
- case OBJ_texeci:
- free(objs[i].data.execi.cmd);
- free(objs[i].data.execi.buffer);
- break;
- case OBJ_top:
- if (info.first_process) {
- free_all_processes();
- info.first_process = NULL;
+ their_addr.sin_family = AF_INET; // host byte order
+ their_addr.sin_port = htons(mail->port); // short, network byte order
+ their_addr.sin_addr = *((struct in_addr *) he->h_addr);
+ memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct
+
+ if (connect
+ (sockfd, (struct sockaddr *) &their_addr,
+ sizeof(struct sockaddr)) == -1) {
+ perror("connect");
+ fail++;
+ continue;
+ }
+ struct timeval timeout;
+ int res;
+ fd_set fdset;
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv");
+ fail++;
+ continue;
}
- break;
- case OBJ_top_mem:
- if (info.first_process) {
- free_all_processes();
- info.first_process = NULL;
+ } else {
+ ERR("IMAP connection failed: timeout");
+ fail++;
+ continue;
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "* OK") != recvbuf) {
+ ERR("IMAP connection failed, probably not an IMAP server");
+ fail++;
+ continue;
+ }
+ strncpy(sendbuf, "a1 login ", MAXDATASIZE);
+ strncat(sendbuf, mail->user,
+ MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, " ", MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, mail->pass,
+ MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, "\n", MAXDATASIZE - strlen(sendbuf) - 1);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send a1");
+ fail++;
+ continue;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv a1");
+ fail++;
+ continue;
}
- break;
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "a1 OK") == NULL) {
+ ERR("IMAP server login failed: %s", recvbuf);
+ fail++;
+ continue;
+ }
+ strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE);
+ strncat(sendbuf, mail->folder,
+ MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, " (MESSAGES UNSEEN)\n",
+ MAXDATASIZE - strlen(sendbuf) - 1);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send a2");
+ fail++;
+ continue;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv a2");
+ fail++;
+ continue;
+ }
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "a2 OK") == NULL) {
+ ERR("IMAP status failed: %s", recvbuf);
+ fail++;
+ continue;
+ }
+ // now we get the data
+ reply = strstr(recvbuf, " (MESSAGES ");
+ reply += 2;
+ *strchr(reply, ')') = '\0';
+ if (reply == NULL) {
+ ERR("Error parsing IMAP response: %s", recvbuf);
+ fail++;
+ continue;
+ } else {
+ pthread_mutex_lock(&(mail->thread_info.mutex));
+ sscanf(reply, "MESSAGES %lu UNSEEN %lu",
+ &mail->messages,
+ &mail->unseen);
+ pthread_mutex_unlock(&(mail->thread_info.mutex));
+ }
+ strncpy(sendbuf, "a3 logout\n", MAXDATASIZE);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send a3");
+ fail++;
+ continue;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv a3");
+ fail++;
+ continue;
+ }
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "a3 OK") == NULL) {
+ ERR("IMAP logout failed: %s", recvbuf);
+ fail++;
+ continue;
+ }
+ close(sockfd);
+ if (strlen(mail->command) > 1 && (mail->unseen > old_unseen || (mail->messages > old_messages && mail->unseen > 0))) { // new mail goodie
+ if (system(mail->command) == -1) {
+ perror("system()");
+ }
+ }
+ fail = 0;
+ old_unseen = mail->unseen;
+ old_messages = mail->messages;
+ mail->last_update = update_time;
+ usleep(100); // prevent race condition
+ if (get_time() - mail->last_update >
+ mail->interval) {
+ continue;
+ } else {
+ unsigned int delay =
+ 1000000.0 * (mail->interval -
+ (get_time() -
+ mail->last_update));
+ if (delay < update_interval * 500000) {
+ delay = update_interval * 1000000;
+ }
+ usleep(delay);
}
}
- free(objs);
- //text_objects = NULL;
- //text_object_count = 0;
+ ERR("exiting imap thread");
+ pthread_exit(NULL);
+ return 0;
}
-void scan_mixer_bar(const char *arg, int *a, int *w, int *h)
-{
- char buf1[64];
- int n;
-
- if (arg && sscanf(arg, "%63s %n", buf1, &n) >= 1) {
- *a = mixer_init(buf1);
- (void) scan_bar(arg + n, w, h);
- } else {
- *a = mixer_init(0);
- (void) scan_bar(arg, w, h);
+void *pop3_thread(struct mail_s *mail)
+{ // pthreads are really beginning to piss me off
+ double update_time;
+ int run_code = threads_runnable;
+ update_time = get_time();
+ int sockfd, numbytes;
+ char recvbuf[MAXDATASIZE];
+ char sendbuf[MAXDATASIZE];
+ char *reply;
+ int fail = 0;
+ unsigned int old_unseen = UINT_MAX;
+ struct hostent *he;
+ struct sockaddr_in their_addr; // connector's address information
+ if ((he = gethostbyname(mail->host)) == NULL) { // get the host info
+ herror("gethostbyname");
+ exit(1);
}
-}
-
-
-/* construct_text_object() creates a new text_object */
-static struct text_object *construct_text_object(const char *s, const char *arg)
-{
- //struct text_object *obj = new_text_object();
- struct text_object *obj = new_text_object_internal();
+ while (threads_runnable == run_code && fail < 5) {
+ if (fail > 0) {
+ ERR("Trying POP3 connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
+ sleep((int)mail->interval);
+ }
+ update_time = get_time();
+ if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
+ perror("socket");
+ fail++;
+ continue;
+ }
-#define OBJ(a, n) if (strcmp(s, #a) == 0) { obj->type = OBJ_##a; need_mask |= (1 << n); {
-#define END ; } } else
+ their_addr.sin_family = AF_INET; // host byte order
+ their_addr.sin_port = htons(mail->port); // short, network byte order
+ their_addr.sin_addr = *((struct in_addr *) he->h_addr);
+ memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct
-#ifdef X11
-if (s[0] == '#') {
- obj->type = OBJ_color;
- obj->data.l = get_x11_color(s);
- } else
-#endif /* X11 */
- OBJ(acpitemp, 0) obj->data.i = open_acpi_temperature(arg);
- END OBJ(acpitempf, 0) obj->data.i = open_acpi_temperature(arg);
- END OBJ(acpiacadapter, 0)
- END OBJ(freq, 0);
- END OBJ(freq_g, 0);
- END OBJ(freq_dyn, 0);
- END OBJ(freq_dyn_g, 0);
- END OBJ(acpifan, 0);
- END OBJ(battery, 0);
- char bat[64];
- if (arg)
- sscanf(arg, "%63s", bat);
- else
- strcpy(bat, "BAT0");
- obj->data.s = strdup(bat);
-#if defined(__linux__)
- END OBJ(i8k_version, INFO_I8K)
- END OBJ(i8k_bios, INFO_I8K)
- END OBJ(i8k_serial, INFO_I8K)
- END OBJ(i8k_cpu_temp, INFO_I8K)
- END OBJ(i8k_cpu_tempf, INFO_I8K)
- END OBJ(i8k_left_fan_status, INFO_I8K)
- END OBJ(i8k_right_fan_status, INFO_I8K)
- END OBJ(i8k_left_fan_rpm, INFO_I8K)
- END OBJ(i8k_right_fan_rpm, INFO_I8K)
- END OBJ(i8k_ac_status, INFO_I8K)
- END OBJ(i8k_buttons_status, INFO_I8K)
-#endif /* __linux__ */
- END OBJ(buffers, INFO_BUFFERS)
- END OBJ(cached, INFO_BUFFERS)
- END OBJ(cpu, INFO_CPU)
- if (arg) {
- if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
- obj->data.cpu_index = atoi(&arg[3]);
- arg += 4;
- } else {obj->data.cpu_index = 0; }
+ if (connect
+ (sockfd, (struct sockaddr *) &their_addr,
+ sizeof(struct sockaddr)) == -1) {
+ perror("connect");
+ fail++;
+ continue;
+ }
+ struct timeval timeout;
+ int res;
+ fd_set fdset;
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv");
+ fail++;
+ continue;
+ }
} else {
- obj->data.cpu_index = 0;
+ ERR("POP3 connection failed: timeout\n");
+ fail++;
+ continue;
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "+OK ") != recvbuf) {
+ ERR("POP3 connection failed, probably not a POP3 server");
+ fail++;
+ continue;
+ }
+ strncpy(sendbuf, "USER ", MAXDATASIZE);
+ strncat(sendbuf, mail->user,
+ MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, "\n", MAXDATASIZE - strlen(sendbuf) - 1);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send USER");
+ fail++;
+ continue;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv USER");
+ fail++;
+ continue;
}
- END OBJ(cpubar, INFO_CPU)
- if (arg) {
- if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
- obj->data.cpu_index = atoi(&arg[3]);
- arg += 4;
}
- else {obj->data.cpu_index = 0;}
- (void) scan_bar(arg, &obj->a, &obj->b);
- } else {
- (void) scan_bar(arg, &obj->a, &obj->b);
- obj->data.cpu_index = 0;
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "+OK ") == NULL) {
+ ERR("POP3 server login failed: %s", recvbuf);
+ fail++;
+ continue;
+ }
+ strncpy(sendbuf, "PASS ", MAXDATASIZE);
+ strncat(sendbuf, mail->pass,
+ MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, "\n", MAXDATASIZE - strlen(sendbuf) - 1);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send PASS");
+ fail++;
+ continue;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv PASS");
+ fail++;
+ continue;
}
- END OBJ(cpugraph, INFO_CPU)
- if (arg) {
- if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
- obj->data.cpu_index = atoi(&arg[3]);
- arg += 4;
}
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
- } else {
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
- obj->data.cpu_index = 0;
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "+OK ") == NULL) {
+ ERR("POP3 server login failed: %s", recvbuf);
+ fail++;
+ continue;
+ }
+ strncpy(sendbuf, "STAT\n", MAXDATASIZE);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send STAT");
+ fail++;
+ continue;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv STAT");
+ fail++;
+ continue;
}
- END OBJ(diskio, INFO_DISKIO)
- END OBJ(diskiograph, INFO_DISKIO) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
- END OBJ(color, 0)
-#ifdef X11
- obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
-#endif /* X11 */
- END
- OBJ(font, 0)
- obj->data.s = scan_font(arg);
- END
- OBJ(downspeed, INFO_NET)
- if(arg) {
- obj->data.net = get_net_stat(arg);
}
- else {
- CRIT_ERR("downspeed needs argument");
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "+OK ") == NULL) {
+ ERR("POP3 status failed: %s", recvbuf);
+ fail++;
+ continue;
}
- END OBJ(downspeedf, INFO_NET)
- if(arg) {
- obj->data.net = get_net_stat(arg);
+ // now we get the data
+ reply = recvbuf + 4;
+ if (reply == NULL) {
+ ERR("Error parsing POP3 response: %s", recvbuf);
+ fail++;
+ continue;
+ } else {
+ pthread_mutex_lock(&(mail->thread_info.mutex));
+ sscanf(reply, "%lu %lu", &mail->unseen,
+ &mail->used);
+// sleep(60);
+ pthread_mutex_unlock(&(mail->thread_info.mutex));
+ }
+ strncpy(sendbuf, "QUIT\n", MAXDATASIZE);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send QUIT");
+ fail++;
+ continue;
}
- else {
- CRIT_ERR("downspeedf needs argument");
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes =
+ recv(sockfd, recvbuf, MAXDATASIZE - 1,
+ 0)) == -1) {
+ perror("recv QUIT");
+ fail++;
+ continue;
+ }
}
- END OBJ(downspeedgraph, INFO_NET)
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "+OK") == NULL) {
+ ERR("POP3 logout failed: %s", recvbuf);
+ fail++;
+ continue;
+ }
+ close(sockfd);
+ if (strlen(mail->command) > 1 && mail->unseen > old_unseen) { // new mail goodie
+ if (system(mail->command) == -1) {
+ perror("system()");
+ }
+ }
+ fail = 0;
+ old_unseen = mail->unseen;
+ mail->last_update = update_time;
+ usleep(100); // prevent race condition
+ if (get_time() - mail->last_update >
+ mail->interval) {
+ continue;
+ } else {
+ unsigned int delay =
+ 1000000.0 * (mail->interval -
+ (get_time() -
+ mail->last_update));
+ if (delay < update_interval * 500000) {
+ delay = update_interval * 1000000;
+ }
+ usleep(delay);
+ }
+ }
+ ERR("exiting pop3 thread");
+ pthread_exit(NULL);
+ return 0;
+}
+
+
+void *threaded_exec(struct text_object *obj) { // pthreads are really beginning to piss me off
+ double update_time;
+ int run_code = threads_runnable;
+ while (threads_runnable == run_code) {
+ update_time = get_time();
+ char *p2 = obj->data.execi.buffer;
+ FILE *fp = popen(obj->data.execi.cmd,"r");
+ pthread_mutex_lock(&(obj->data.execi.thread_info.mutex));
+ int n2 = fread(p2, 1, TEXT_BUFFER_SIZE, fp);
+ (void) pclose(fp);
+ p2[n2] = '\0';
+ if (n2 && p2[n2 - 1] == '\n') {
+ p2[n2 - 1] = '\0';
+ }
+ while (*p2) {
+ if (*p2 == '\001') {
+ *p2 = ' ';
+ }
+ p2++;
+ }
+ pthread_mutex_unlock(&(obj->data.execi.thread_info.mutex));
+ obj->data.execi.last_update = update_time;
+ usleep(100); // prevent race condition
+ if (get_time() - obj->data.execi.last_update > obj->data.execi.interval) {
+ continue;
+ } else {
+ unsigned int delay = 1000000.0 * (obj->data.execi.interval -(get_time() - obj->data.execi.last_update));
+ if (delay < update_interval * 500000) {
+ delay = update_interval * 1000000;
+ }
+ usleep(delay);
+ }
+ }
+ ERR("exiting thread");
+ pthread_exit(NULL);
+ return 0;
+}
+
+static struct text_object *new_text_object_internal()
+{
+ struct text_object *obj = malloc(sizeof(struct text_object));
+ memset(obj, 0, sizeof(struct text_object));
+ return obj;
+}
+
+#ifdef MLDONKEY
+void ml_cleanup()
+{
+ if (mlconfig.mldonkey_hostname) {
+ free(mlconfig.mldonkey_hostname);
+ mlconfig.mldonkey_hostname = NULL;
+ }
+}
+#endif
+
+static void free_text_objects(unsigned int count, struct text_object *objs)
+{
+ unsigned int i;
+ for (i = 0; i < count; i++) {
+ switch (objs[i].type) {
+ case OBJ_acpitemp:
+ close(objs[i].data.i);
+ break;
+ case OBJ_acpitempf:
+ close(objs[i].data.i);
+ break;
+ case OBJ_i2c:
+ close(objs[i].data.i2c.fd);
+ break;
+ case OBJ_time:
+ free(objs[i].data.s);
+ break;
+ case OBJ_utime:
+ free(objs[i].data.s);
+ break;
+ case OBJ_tztime:
+ free(objs[i].data.tztime.tz);
+ free(objs[i].data.tztime.fmt);
+ break;
+ case OBJ_imap:
+ free(info.mail);
+ break;
+ case OBJ_imap_unseen:
+ if (!objs[i].global_mode) {
+ free(objs[i].data.mail);
+ }
+ break;
+ case OBJ_imap_messages:
+ if (!objs[i].global_mode) {
+ free(objs[i].data.mail);
+ }
+ break;
+ case OBJ_pop3:
+ free(info.mail);
+ break;
+ case OBJ_pop3_unseen:
+ if (!objs[i].global_mode) {
+ free(objs[i].data.mail);
+ }
+ break;
+ case OBJ_pop3_used:
+ if (!objs[i].global_mode) {
+ free(objs[i].data.mail);
+ }
+ break;
+ case OBJ_if_existing:
+ case OBJ_if_mounted:
+ case OBJ_if_running:
+ free(objs[i].data.ifblock.s);
+ break;
+ case OBJ_tail:
+ free(objs[i].data.tail.logfile);
+ free(objs[i].data.tail.buffer);
+ break;
+ case OBJ_text: case OBJ_font:
+ free(objs[i].data.s);
+ break;
+ case OBJ_image:
+ free(objs[i].data.s);
+ break;
+ case OBJ_exec:
+ free(objs[i].data.s);
+ break;
+ case OBJ_execbar:
+ free(objs[i].data.s);
+ break;
+ case OBJ_execgraph:
+ free(objs[i].data.s);
+ break;
+ /* case OBJ_execibar:
+ free(objs[i].data.s);
+ break;
+ case OBJ_execigraph:
+ free(objs[i].data.s);
+ break;*/
+#ifdef HAVE_ICONV
+ case OBJ_iconv_start:
+ free_iconv();
+ break;
+#endif
+#ifdef MPD
+ case OBJ_mpd_title:
+ if (info.mpd.title) {
+ free(info.mpd.title);
+ info.mpd.title = 0;
+ }
+ break;
+ case OBJ_mpd_artist:
+ if (info.mpd.artist) {
+ free(info.mpd.artist);
+ info.mpd.artist = 0;
+ }
+ break;
+ case OBJ_mpd_album:
+ if (info.mpd.album) {
+ free(info.mpd.album);
+ info.mpd.album = 0;
+ }
+ break;
+ case OBJ_mpd_random:
+ if (info.mpd.random) {
+ free(info.mpd.random);
+ info.mpd.random = 0;
+ }
+ break;
+ case OBJ_mpd_repeat:
+ if (info.mpd.repeat) {
+ free(info.mpd.repeat);
+ info.mpd.repeat = 0;
+ }
+ break;
+ case OBJ_mpd_track:
+ if (info.mpd.track) {
+ free(info.mpd.track);
+ info.mpd.track = 0;
+ }
+ break;
+ case OBJ_mpd_name:
+ if (info.mpd.name) {
+ free(info.mpd.name);
+ info.mpd.name = 0;
+ }
+ break;
+ case OBJ_mpd_file:
+ if (info.mpd.file) {
+ free(info.mpd.file);
+ info.mpd.file = 0;
+ }
+ break;
+ case OBJ_mpd_status:
+ if (info.mpd.status) {
+ free(info.mpd.status);
+ info.mpd.status = 0;
+ }
+ break;
+ case OBJ_mpd_smart:
+ if (info.mpd.artist) {
+ free(info.mpd.artist);
+ info.mpd.artist = 0;
+ }
+ if (info.mpd.title) {
+ free(info.mpd.title);
+ info.mpd.title = 0;
+ }
+ if (info.mpd.file) {
+ free(info.mpd.file);
+ info.mpd.file = 0;
+ }
+ break;
+ case OBJ_mpd_host:
+#endif
+#ifdef XMMS2
+ case OBJ_xmms2_artist:
+ if (info.xmms2.artist) {
+ free(info.xmms2.artist);
+ info.xmms2.artist = 0;
+ }
+ break;
+ case OBJ_xmms2_album:
+ if (info.xmms2.album) {
+ free(info.xmms2.album);
+ info.xmms2.album = 0;
+ }
+ break;
+ case OBJ_xmms2_title:
+ if (info.xmms2.title) {
+ free(info.xmms2.title);
+ info.xmms2.title = 0;
+ }
+ break;
+ case OBJ_xmms2_genre:
+ if (info.xmms2.genre) {
+ free(info.xmms2.genre);
+ info.xmms2.genre = 0;
+ }
+ break;
+ case OBJ_xmms2_comment:
+ if (info.xmms2.comment) {
+ free(info.xmms2.comment);
+ info.xmms2.comment = 0;
+ }
+ break;
+ case OBJ_xmms2_decoder:
+ if (info.xmms2.decoder) {
+ free(info.xmms2.decoder);
+ info.xmms2.url = 0;
+ }
+ break;
+ case OBJ_xmms2_transport:
+ if (info.xmms2.transport) {
+ free(info.xmms2.transport);
+ info.xmms2.url = 0;
+ }
+ break;
+ case OBJ_xmms2_url:
+ if (info.xmms2.url) {
+ free(info.xmms2.url);
+ info.xmms2.url = 0;
+ }
+ break;
+ case OBJ_xmms2_date:
+ if (info.xmms2.date) {
+ free(info.xmms2.date);
+ info.xmms2.date = 0;
+ }
+ break;
+ case OBJ_xmms2_status:
+ if (info.xmms2.status) {
+ free(info.xmms2.status);
+ info.xmms2.status = 0;
+ }
+ break;
+ case OBJ_xmms2_smart:
+ if (info.xmms2.artist) {
+ free(info.xmms2.artist);
+ info.xmms2.artist = 0;
+ }
+ if (info.xmms2.title) {
+ free(info.xmms2.title);
+ info.xmms2.title = 0;
+ }
+ if (info.xmms2.url) {
+ free(info.xmms2.url);
+ info.xmms2.url = 0;
+ }
+ break;
+#endif
+#ifdef BMPX
+ case OBJ_bmpx_title:
+ case OBJ_bmpx_artist:
+ case OBJ_bmpx_album:
+ case OBJ_bmpx_track:
+ case OBJ_bmpx_uri:
+ case OBJ_bmpx_bitrate:
+#endif
+ case OBJ_pre_exec:
+ case OBJ_battery:
+ free(objs[i].data.s);
+ break;
+
+ case OBJ_execi:
+ free(objs[i].data.execi.cmd);
+ free(objs[i].data.execi.buffer);
+ break;
+ case OBJ_texeci:
+ free(objs[i].data.execi.cmd);
+ free(objs[i].data.execi.buffer);
+ break;
+ case OBJ_top:
+ if (info.first_process) {
+ free_all_processes();
+ info.first_process = NULL;
+ }
+ break;
+ case OBJ_top_mem:
+ if (info.first_process) {
+ free_all_processes();
+ info.first_process = NULL;
+ }
+ break;
+#ifdef HDDTEMP
+ case OBJ_hddtemp:
+ free(objs[i].data.hddtemp.dev);
+ free(objs[i].data.hddtemp.addr);
+ break;
+#endif
+ }
+ }
+ free(objs);
+ //text_objects = NULL;
+ //text_object_count = 0;
+}
+
+void scan_mixer_bar(const char *arg, int *a, int *w, int *h)
+{
+ char buf1[64];
+ int n;
+
+ if (arg && sscanf(arg, "%63s %n", buf1, &n) >= 1) {
+ *a = mixer_init(buf1);
+ (void) scan_bar(arg + n, w, h);
+ } else {
+ *a = mixer_init(0);
+ (void) scan_bar(arg, w, h);
+ }
+}
+
+
+/* construct_text_object() creates a new text_object */
+static struct text_object *construct_text_object(const char *s, const char *arg, unsigned int object_count, struct text_object *text_objects, long line)
+{
+ //struct text_object *obj = new_text_object();
+ struct text_object *obj = new_text_object_internal();
+ obj->line = line;
+
+#define OBJ(a, n) if (strcmp(s, #a) == 0) { obj->type = OBJ_##a; need_mask |= (1 << n); {
+#define END ; } } else
+
+#ifdef X11
+ if (s[0] == '#') {
+ obj->type = OBJ_color;
+ obj->data.l = get_x11_color(s);
+ } else
+#endif /* X11 */
+ OBJ(acpitemp, 0) obj->data.i = open_acpi_temperature(arg);
+ END OBJ(acpitempf, 0) obj->data.i = open_acpi_temperature(arg);
+ END OBJ(acpiacadapter, 0)
+#if defined(__linux__)
+ END OBJ(freq, 0)
+ get_cpu_count();
+ if (!arg
+ || !isdigit(arg[0])
+ || strlen(arg) >=2
+ || atoi(&arg[0])==0
+ || (unsigned int)atoi(&arg[0])>info.cpu_count)
+ {
+ obj->data.cpu_index=1;
+// ERR("freq: Invalid CPU number or you don't have that many CPUs! Displaying the clock for CPU 1.");
+ }
+ else
+ {
+ obj->data.cpu_index=atoi(&arg[0]);
+ }
+ obj->a = 1;
+ END OBJ(freq_g, 0)
+ get_cpu_count();
+ if (!arg
+ || !isdigit(arg[0])
+ || strlen(arg) >=2
+ || atoi(&arg[0])==0
+ || (unsigned int)atoi(&arg[0])>info.cpu_count)
+ {
+ obj->data.cpu_index=1;
+// ERR("freq_g: Invalid CPU number or you don't have that many CPUs! Displaying the clock for CPU 1.");
+ }
+ else
+ {
+ obj->data.cpu_index=atoi(&arg[0]);
+ }
+ obj->a = 1;
+ END OBJ(voltage_mv, 0)
+ get_cpu_count();
+ if (!arg
+ || !isdigit(arg[0])
+ || strlen(arg) >=2
+ || atoi(&arg[0])==0
+ || (unsigned int)atoi(&arg[0])>info.cpu_count)
+ {
+ obj->data.cpu_index=1;
+// ERR("voltage_mv: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
+ }
+ else
+ {
+ obj->data.cpu_index=atoi(&arg[0]);
+ }
+ obj->a = 1;
+ END OBJ(voltage_v, 0)
+ get_cpu_count();
+ if (!arg
+ || !isdigit(arg[0])
+ || strlen(arg) >=2
+ || atoi(&arg[0])==0
+ || (unsigned int)atoi(&arg[0])>info.cpu_count)
+ {
+ obj->data.cpu_index=1;
+// ERR("voltage_v: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
+ }
+ else
+ {
+ obj->data.cpu_index=atoi(&arg[0]);
+ }
+ obj->a = 1;
+#else
+ END OBJ(freq, 0);
+ END OBJ(freq_g, 0);
+#endif /* __linux__ */
+ END OBJ(freq_dyn, 0);
+ END OBJ(freq_dyn_g, 0);
+ END OBJ(acpifan, 0);
+ END OBJ(battery, 0);
+ char bat[64];
+ if (arg)
+ sscanf(arg, "%63s", bat);
+ else
+ strcpy(bat, "BAT0");
+ obj->data.s = strdup(bat);
+#if defined(__linux__)
+ END OBJ(i8k_version, INFO_I8K)
+ END OBJ(i8k_bios, INFO_I8K)
+ END OBJ(i8k_serial, INFO_I8K)
+ END OBJ(i8k_cpu_temp, INFO_I8K)
+ END OBJ(i8k_cpu_tempf, INFO_I8K)
+ END OBJ(i8k_left_fan_status, INFO_I8K)
+ END OBJ(i8k_right_fan_status, INFO_I8K)
+ END OBJ(i8k_left_fan_rpm, INFO_I8K)
+ END OBJ(i8k_right_fan_rpm, INFO_I8K)
+ END OBJ(i8k_ac_status, INFO_I8K)
+ END OBJ(i8k_buttons_status, INFO_I8K)
+ END OBJ(ibm_fan, 0)
+ END OBJ(ibm_temps, 0)
+ if (!isdigit(arg[0])
+ || strlen(arg) >=2
+ || atoi(&arg[0]) >=8)
+ {
+ obj->data.sensor=0;
+ ERR("Invalid temperature sensor! Sensor number must be 0 to 7. Using 0 (CPU temp sensor).");
+ }
+ obj->data.sensor = atoi(&arg[0]);
+ END OBJ(ibm_volume, 0)
+ END OBJ(ibm_brightness, 0)
+ END OBJ(pb_battery, 0)
+ if (arg && strcmp(arg, "status") == 0) {
+ obj->data.i = PB_BATT_STATUS;
+ } else if (arg && strcmp(arg, "percent") == 0) {
+ obj->data.i = PB_BATT_PERCENT;
+ } else if (arg && strcmp(arg, "time") == 0) {
+ obj->data.i = PB_BATT_TIME;
+ } else {
+ ERR("pb_battery: needs one argument: status, percent or time");
+ free(obj);
+ return NULL;
+ }
+
+#endif /* __linux__ */
+ END OBJ(buffers, INFO_BUFFERS)
+ END OBJ(cached, INFO_BUFFERS)
+ END OBJ(cpu, INFO_CPU)
+ if (arg) {
+ if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
+ obj->data.cpu_index = atoi(&arg[3]);
+ arg += 4;
+ } else {obj->data.cpu_index = 0; }
+ } else {
+ obj->data.cpu_index = 0;
+ }
+ END OBJ(cpubar, INFO_CPU)
+ if (arg) {
+ if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
+ obj->data.cpu_index = atoi(&arg[3]);
+ arg += 4;
+ }
+ else {obj->data.cpu_index = 0;}
+ (void) scan_bar(arg, &obj->a, &obj->b);
+ } else {
+ (void) scan_bar(arg, &obj->a, &obj->b);
+ obj->data.cpu_index = 0;
+ }
+ END OBJ(cpugraph, INFO_CPU)
+ if (arg) {
+ if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
+ obj->data.cpu_index = atoi(&arg[3]);
+ arg += 4;
+ }
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ } else {
(void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ obj->data.cpu_index = 0;
+ }
+ END OBJ(diskio, INFO_DISKIO)
+ END OBJ(diskiograph, INFO_DISKIO) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ END OBJ(color, 0)
+#ifdef X11
+ obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
+#endif /* X11 */
+ END
+ OBJ(font, 0)
+ obj->data.s = scan_font(arg);
+ END
+ OBJ(downspeed, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("downspeed needs argument");
+ }
+ END OBJ(downspeedf, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("downspeedf needs argument");
+ }
+ END OBJ(downspeedgraph, INFO_NET)
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
char buf[64];
sscanf(arg, "%63s %*i,%*i %*i", buf);
obj->data.net = get_net_stat(buf);
obj->b = 25;
}
}
- END OBJ(
- else
- , 0)
- if (blockdepth) {
- text_objects[blockstart[blockdepth - 1] -
- 1].data.ifblock.pos = text_object_count;
- blockstart[blockdepth - 1] = text_object_count;
- obj->data.ifblock.pos = text_object_count + 2;
- } else {
- ERR("$else: no matching $if_*");
- }
+ END OBJ(else, 0)
+ if (blockdepth) {
+ (text_objects[blockstart[blockdepth - 1]]).data.ifblock.pos = object_count;
+ blockstart[blockdepth - 1] = object_count;
+ obj->data.ifblock.pos = object_count + 2;
+ } else {
+ ERR("$else: no matching $if_*");
+ }
END OBJ(endif, 0)
- if (blockdepth) {
- blockdepth--;
- text_objects[blockstart[blockdepth] - 1].data.ifblock.pos =
- text_object_count;
- } else {
- ERR("$endif: no matching $if_*");
- }
+ if (blockdepth) {
+ blockdepth--;
+ text_objects[blockstart[blockdepth]].data.ifblock.pos = object_count;
+ } else {
+ ERR("$endif: no matching $if_*");
+ }
+ END
+ OBJ(image, 0) obj->data.s = strdup(arg ? arg : "");
END
#ifdef HAVE_POPEN
- OBJ(exec, 0) obj->data.s = strdup(arg ? arg : "");
+ OBJ(exec, 0) obj->data.s = strdup(arg ? arg : "");
END OBJ(execbar, 0) obj->data.s = strdup(arg ? arg : "");
END OBJ(execgraph, 0) obj->data.s = strdup(arg ? arg : "");
END OBJ(execibar, 0) unsigned int n;
obj->type = OBJ_text;
snprintf(buf, 256, "${%s}", s);
obj->data.s = strdup(buf);
- } else {
- obj->data.execi.cmd = strdup(arg + n);
- }
+ } else {
+ obj->data.execi.cmd = strdup(arg + n);
+ }
END OBJ(execigraph, 0) unsigned int n;
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
char buf[256];
END OBJ(execi, 0) unsigned int n;
if (!arg
- || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
+ || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
char buf[256];
ERR("${execi <interval> command}");
obj->type = OBJ_text;
} else {
obj->data.execi.cmd = strdup(arg + n);
obj->data.execi.buffer =
- (char *) calloc(1, TEXT_BUFFER_SIZE);
+ (char *) calloc(1, TEXT_BUFFER_SIZE);
}
END OBJ(texeci, 0) unsigned int n;
- if (!arg
- || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
+ if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
char buf[256];
ERR("${texeci <interval> command}");
obj->type = OBJ_text;
snprintf(buf, 256, "${%s}", s);
obj->data.s = strdup(buf);
- } else {
- obj->data.execi.cmd = strdup(arg + n);
- obj->data.execi.buffer =
- (char *) calloc(1, TEXT_BUFFER_SIZE);
- }
+ } else {
+ obj->data.execi.cmd = strdup(arg + n);
+ obj->data.execi.buffer =
+ (char *) calloc(1, TEXT_BUFFER_SIZE);
+ }
+ obj->data.execi.pos = -1;
END OBJ(pre_exec, 0) obj->type = OBJ_text;
if (arg) {
FILE *fp = popen(arg, "r");
obj->data.s = strdup("");
END
#endif
- OBJ(fs_bar, INFO_FS) obj->data.fsbar.h = 4;
+ OBJ(fs_bar, INFO_FS) obj->data.fsbar.h = 4;
arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
if (arg) {
while (isspace(*arg))
arg = "/";
obj->data.fsbar.fs = prepare_fs_stat(arg);
END OBJ(fs_free, INFO_FS) if (!arg)
- arg = "/";
+ arg = "/";
obj->data.fs = prepare_fs_stat(arg);
END OBJ(fs_used_perc, INFO_FS) if (!arg)
- arg = "/";
+ arg = "/";
obj->data.fs = prepare_fs_stat(arg);
END OBJ(fs_free_perc, INFO_FS) if (!arg)
- arg = "/";
+ arg = "/";
obj->data.fs = prepare_fs_stat(arg);
END OBJ(fs_size, INFO_FS) if (!arg)
- arg = "/";
+ arg = "/";
obj->data.fs = prepare_fs_stat(arg);
END OBJ(fs_used, INFO_FS) if (!arg)
- arg = "/";
+ arg = "/";
obj->data.fs = prepare_fs_stat(arg);
END OBJ(hr, 0) obj->data.i = arg ? atoi(arg) : 1;
END OBJ(offset, 0) obj->data.i = arg ? atoi(arg) : 1;
END OBJ(voffset, 0) obj->data.i = arg ? atoi(arg) : 1;
+ END OBJ(goto, 0)
+
+ if (!arg) {
+ ERR("goto needs arguments");
+ obj->type = OBJ_text;
+ obj->data.s = strdup("${goto}");
+ return NULL;
+ }
+
+ obj->data.i = atoi(arg);
+
+ END OBJ(tab, 0)
+ int a = 10, b = 0;
+ if (arg) {
+ if (sscanf(arg, "%d %d", &a, &b) != 2)
+ sscanf(arg, "%d", &b);
+ }
+ if (a <= 0)
+ a = 1;
+ obj->data.pair.a = a;
+ obj->data.pair.b = b;
+
END OBJ(i2c, INFO_I2C) char buf1[64], buf2[64];
int n;
* default device */
sscanf(arg, "%63s %d", buf2, &n);
obj->data.i2c.fd =
- open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg,
- obj->data.i2c.devtype);
+ open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg,
+ obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63);
} else {
obj->data.i2c.fd =
- open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg,
- obj->data.i2c.devtype);
+ open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg,
+ obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63);
}
END OBJ(top, INFO_TOP)
- char buf[64];
+ char buf[64];
int n;
if (!arg) {
ERR("top needs arguments");
return NULL;
}
END OBJ(top_mem, INFO_TOP)
- char buf[64];
+ char buf[64];
int n;
if (!arg) {
ERR("top_mem needs arguments");
CRIT_ERR("linkstatus needs argument");
}
END OBJ(tail, 0)
- char buf[64];
+ char buf[64];
int n1, n2;
if (!arg) {
ERR("tail needs arguments");
fp = fopen(buf, "r");
if (fp) {
obj->data.tail.logfile =
- malloc(TEXT_BUFFER_SIZE);
+ malloc(TEXT_BUFFER_SIZE);
strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1 - 1;
obj->data.tail.interval =
- update_interval * 2;
+ update_interval * 2;
fclose(fp);
} else {
//fclose (fp);
} else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
if (n1 < 1 || n1 > 30) {
CRIT_ERR
- ("invalid arg for tail, number of lines must be between 1 and 30");
+ ("invalid arg for tail, number of lines must be between 1 and 30");
return NULL;
} else if (n2 < 1 || n2 < update_interval) {
CRIT_ERR
- ("invalid arg for tail, interval must be greater than 0 and Conky's interval");
+ ("invalid arg for tail, interval must be greater than 0 and Conky's interval");
return NULL;
} else {
FILE *fp;
fp = fopen(buf, "r");
if (fp != NULL) {
obj->data.tail.logfile =
- malloc(TEXT_BUFFER_SIZE);
+ malloc(TEXT_BUFFER_SIZE);
strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1 - 1;
obj->data.tail.interval = n2;
}
obj->data.tail.buffer = malloc(TEXT_BUFFER_SIZE * 20); /* asumming all else worked */
END OBJ(head, 0)
- char buf[64];
+ char buf[64];
int n1, n2;
if (!arg) {
ERR("head needs arguments");
fp = fopen(buf, "r");
if (fp != NULL) {
obj->data.tail.logfile =
- malloc(TEXT_BUFFER_SIZE);
+ malloc(TEXT_BUFFER_SIZE);
strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1 - 1;
obj->data.tail.interval =
- update_interval * 2;
+ update_interval * 2;
fclose(fp);
} else {
//fclose (fp);
} else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
if (n1 < 1 || n1 > 30) {
CRIT_ERR
- ("invalid arg for head, number of lines must be between 1 and 30");
+ ("invalid arg for head, number of lines must be between 1 and 30");
return NULL;
} else if (n2 < 1 || n2 < update_interval) {
CRIT_ERR
- ("invalid arg for head, interval must be greater than 0 and Conky's interval");
+ ("invalid arg for head, interval must be greater than 0 and Conky's interval");
return NULL;
} else {
FILE *fp;
fp = fopen(buf, "r");
if (fp != NULL) {
obj->data.tail.logfile =
- malloc(TEXT_BUFFER_SIZE);
+ malloc(TEXT_BUFFER_SIZE);
strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1 - 1;
obj->data.tail.interval = n2;
obj->data.loadavg[1] = (r >= 2) ? (unsigned char) b : 0;
obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0;
END OBJ(if_existing, 0)
- if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
- CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
- }
+ if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
+ CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
+ }
if (!arg) {
ERR("if_existing needs an argument");
obj->data.ifblock.s = 0;
} else
obj->data.ifblock.s = strdup(arg);
- blockstart[blockdepth] = text_object_count;
- obj->data.ifblock.pos = text_object_count + 2;
+ blockstart[blockdepth] = object_count;
+ obj->data.ifblock.pos = object_count + 2;
blockdepth++;
END OBJ(if_mounted, 0)
- if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
- CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
- }
+ if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
+ CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
+ }
if (!arg) {
ERR("if_mounted needs an argument");
obj->data.ifblock.s = 0;
} else
obj->data.ifblock.s = strdup(arg);
- blockstart[blockdepth] = text_object_count;
- obj->data.ifblock.pos = text_object_count + 2;
+ blockstart[blockdepth] = object_count;
+ obj->data.ifblock.pos = object_count + 2;
blockdepth++;
END OBJ(if_running, 0)
- if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
- CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
- }
+ if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
+ CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
+ }
if (arg) {
char buf[256];
snprintf(buf, 256, "pidof %s >/dev/null", arg);
ERR("if_running needs an argument");
obj->data.ifblock.s = 0;
}
- blockstart[blockdepth] = text_object_count;
- obj->data.ifblock.pos = text_object_count + 2;
+ blockstart[blockdepth] = object_count;
+ obj->data.ifblock.pos = object_count + 2;
blockdepth++;
END OBJ(kernel, 0)
- END OBJ(machine, 0)
- END OBJ(mails, INFO_MAIL)
- END OBJ(mem, INFO_MEM)
- END OBJ(memmax, INFO_MEM)
- END OBJ(memperc, INFO_MEM)
- END OBJ(membar, INFO_MEM)
- (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ END OBJ(machine, 0)
+ END OBJ(mails, INFO_MAIL)
+ END OBJ(mem, INFO_MEM)
+ END OBJ(memmax, INFO_MEM)
+ END OBJ(memperc, INFO_MEM)
+ END OBJ(membar, INFO_MEM)
+ (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(memgraph, INFO_MEM)
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
END OBJ(mixer, INFO_MIXER) obj->data.l = mixer_init(arg);
END OBJ(mixerl, INFO_MIXER) obj->data.l = mixer_init(arg);
END OBJ(mixerr, INFO_MIXER) obj->data.l = mixer_init(arg);
END OBJ(mixerbar, INFO_MIXER)
- scan_mixer_bar(arg, &obj->data.mixerbar.l,
- &obj->data.mixerbar.w, &obj->data.mixerbar.h);
+ scan_mixer_bar(arg, &obj->data.mixerbar.l,
+ &obj->data.mixerbar.w, &obj->data.mixerbar.h);
END OBJ(mixerlbar, INFO_MIXER)
- scan_mixer_bar(arg, &obj->data.mixerbar.l,
- &obj->data.mixerbar.w, &obj->data.mixerbar.h);
+ scan_mixer_bar(arg, &obj->data.mixerbar.l,
+ &obj->data.mixerbar.w, &obj->data.mixerbar.h);
END OBJ(mixerrbar, INFO_MIXER)
- scan_mixer_bar(arg, &obj->data.mixerbar.l,
- &obj->data.mixerbar.w, &obj->data.mixerbar.h);
+ scan_mixer_bar(arg, &obj->data.mixerbar.l,
+ &obj->data.mixerbar.w, &obj->data.mixerbar.h);
END
#ifdef MLDONKEY
- OBJ(ml_upload_counter, INFO_MLDONKEY)
- END OBJ(ml_download_counter, INFO_MLDONKEY)
- END OBJ(ml_nshared_files, INFO_MLDONKEY)
- END OBJ(ml_shared_counter, INFO_MLDONKEY)
- END OBJ(ml_tcp_upload_rate, INFO_MLDONKEY)
- END OBJ(ml_tcp_download_rate, INFO_MLDONKEY)
- END OBJ(ml_udp_upload_rate, INFO_MLDONKEY)
- END OBJ(ml_udp_download_rate, INFO_MLDONKEY)
- END OBJ(ml_ndownloaded_files, INFO_MLDONKEY)
- END OBJ(ml_ndownloading_files, INFO_MLDONKEY) END
+ OBJ(ml_upload_counter, INFO_MLDONKEY)
+ END OBJ(ml_download_counter, INFO_MLDONKEY)
+ END OBJ(ml_nshared_files, INFO_MLDONKEY)
+ END OBJ(ml_shared_counter, INFO_MLDONKEY)
+ END OBJ(ml_tcp_upload_rate, INFO_MLDONKEY)
+ END OBJ(ml_tcp_download_rate, INFO_MLDONKEY)
+ END OBJ(ml_udp_upload_rate, INFO_MLDONKEY)
+ END OBJ(ml_udp_download_rate, INFO_MLDONKEY)
+ END OBJ(ml_ndownloaded_files, INFO_MLDONKEY)
+ END OBJ(ml_ndownloading_files, INFO_MLDONKEY) END
#endif
- OBJ(new_mails, INFO_MAIL)
- END OBJ(nodename, 0)
- END OBJ(processes, INFO_PROCS)
- END OBJ(running_processes, INFO_RUN_PROCS)
- END OBJ(shadecolor, 0)
+ OBJ(new_mails, INFO_MAIL)
+ END OBJ(nodename, 0)
+ END OBJ(processes, INFO_PROCS)
+ END OBJ(running_processes, INFO_RUN_PROCS)
+ END OBJ(shadecolor, 0)
#ifdef X11
- obj->data.l = arg ? get_x11_color(arg) : default_bg_color;
+ obj->data.l = arg ? get_x11_color(arg) : default_bg_color;
#endif /* X11 */
END OBJ(outlinecolor, 0)
#ifdef X11
- obj->data.l = arg ? get_x11_color(arg) : default_out_color;
+ obj->data.l = arg ? get_x11_color(arg) : default_out_color;
#endif /* X11 */
END OBJ(stippled_hr, 0)
#ifdef X11
-int a = stippled_borders, b = 1;
+ int a = stippled_borders, b = 1;
if (arg) {
if (sscanf(arg, "%d %d", &a, &b) != 2)
sscanf(arg, "%d", &b);
obj->data.pair.b = b;
#endif /* X11 */
END OBJ(swap, INFO_MEM)
- END OBJ(swapmax, INFO_MEM)
- END OBJ(swapperc, INFO_MEM)
- END OBJ(swapbar, INFO_MEM)
- (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ END OBJ(swapmax, INFO_MEM)
+ END OBJ(swapperc, INFO_MEM)
+ END OBJ(swapbar, INFO_MEM)
+ (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(sysname, 0) END OBJ(temp1, INFO_I2C) obj->type = OBJ_i2c;
obj->data.i2c.fd =
- open_i2c_sensor(0, "temp", 1, &obj->data.i2c.arg,
- obj->data.i2c.devtype);
+ open_i2c_sensor(0, "temp", 1, &obj->data.i2c.arg,
+ obj->data.i2c.devtype);
END OBJ(temp2, INFO_I2C) obj->type = OBJ_i2c;
obj->data.i2c.fd =
- open_i2c_sensor(0, "temp", 2, &obj->data.i2c.arg,
- obj->data.i2c.devtype);
+ open_i2c_sensor(0, "temp", 2, &obj->data.i2c.arg,
+ obj->data.i2c.devtype);
END OBJ(time, 0) obj->data.s = strdup(arg ? arg : "%F %T");
END OBJ(utime, 0) obj->data.s = strdup(arg ? arg : "%F %T");
+ END OBJ(tztime, 0)
+ char buf1[256], buf2[256], *fmt, *tz;
+ fmt = tz = NULL;
+ if (arg) {
+ int nArgs = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
+ switch (nArgs) {
+ case 2:
+ tz = buf1;
+ case 1:
+ fmt = buf2;
+ }
+ }
+
+ obj->data.tztime.fmt = strdup(fmt ? fmt : "%F %T");
+ obj->data.tztime.tz = tz ? strdup(tz) : NULL;
+#ifdef HAVE_ICONV
+ END OBJ(iconv_start, 0)
+ if (iconv_converting) {
+ CRIT_ERR("You must stop your last iconv conversion before starting another");
+ }
+ if (arg) {
+ char iconv_from[CODEPAGE_LENGTH];
+ char iconv_to[CODEPAGE_LENGTH];
+ if (sscanf(arg, "%s %s", iconv_from, iconv_to) != 2) {
+ CRIT_ERR("Invalid arguments for iconv_start");
+ } else {
+ iconv_t new_iconv;
+ new_iconv = iconv_open(iconv_to, iconv_from);
+ if (new_iconv == (iconv_t)(-1)) {
+ ERR("Can't convert from %s to %s.", iconv_from, iconv_to);
+ } else {
+ obj->a = register_iconv(&new_iconv);
+ iconv_converting = 1;
+ }
+ }
+ } else {
+ CRIT_ERR("Iconv requires arguments");
+ }
+ END OBJ(iconv_stop, 0)
+ iconv_converting = 0;
+
+#endif
END OBJ(totaldown, INFO_NET)
if(arg) {
obj->data.net = get_net_stat(arg);
CRIT_ERR("totaldown needs argument");
}
END OBJ(totalup, INFO_NET) obj->data.net = get_net_stat(arg);
- if(arg) {
- obj->data.net = get_net_stat(arg);
- }
- else {
- CRIT_ERR("totalup needs argument");
- }
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("totalup needs argument");
+ }
END OBJ(updates, 0)
- END OBJ(alignr, 0) obj->data.i = arg ? atoi(arg) : 0;
+ END OBJ(alignr, 0) obj->data.i = arg ? atoi(arg) : 0;
END OBJ(alignc, 0) obj->data.i = arg ? atoi(arg) : 0;
END OBJ(upspeed, INFO_NET)
if(arg) {
}
END OBJ(upspeedgraph, INFO_NET)
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
char buf[64];
sscanf(arg, "%63s %*i,%*i %*i", buf);
obj->data.net = get_net_stat(buf);
}
}
END OBJ(uptime_short, INFO_UPTIME) END OBJ(uptime, INFO_UPTIME) END
- OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
+ OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
#if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
- OBJ(apm_adapter, 0) END
- OBJ(apm_battery_life, 0) END
- OBJ(apm_battery_time, 0) END
+ OBJ(apm_adapter, 0) END
+ OBJ(apm_battery_life, 0) END
+ OBJ(apm_battery_time, 0) END
#endif /* __FreeBSD__ */
#ifdef SETI
- OBJ(seti_prog, INFO_SETI) END OBJ(seti_progbar, INFO_SETI)
- (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ OBJ(seti_prog, INFO_SETI) END OBJ(seti_progbar, INFO_SETI)
+ (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(seti_credit, INFO_SETI) END
#endif
+ OBJ(imap_unseen, 0)
+ if (arg) {
+ // proccss
+ obj->data.mail = parse_mail_args(IMAP, arg);
+ obj->global_mode = 0;
+ } else {
+ obj->global_mode = 1;
+ }
+ END
+ OBJ(imap_messages, 0)
+ if (arg) {
+ // proccss
+ obj->data.mail = parse_mail_args(IMAP, arg);
+ obj->global_mode = 0;
+ } else {
+ obj->global_mode = 1;
+ }
+ END
+ OBJ(pop3_unseen, 0)
+ if (arg) {
+ // proccss
+ obj->data.mail = parse_mail_args(POP3, arg);
+ obj->global_mode = 0;
+ } else {
+ obj->global_mode = 1;
+ }
+ END
+ OBJ(pop3_used, 0)
+ if (arg) {
+ // proccss
+ obj->data.mail = parse_mail_args(POP3, arg);
+ obj->global_mode = 0;
+ } else {
+ obj->global_mode = 1;
+ }
+ END
#ifdef MPD
- OBJ(mpd_artist, INFO_MPD)
- END OBJ(mpd_title, INFO_MPD)
- END OBJ(mpd_random, INFO_MPD)
- END OBJ(mpd_repeat, INFO_MPD)
- END OBJ(mpd_elapsed, INFO_MPD)
- END OBJ(mpd_length, INFO_MPD)
- END OBJ(mpd_track, INFO_MPD)
- END OBJ(mpd_percent, INFO_MPD)
- END OBJ(mpd_album, INFO_MPD) END OBJ(mpd_vol,
- INFO_MPD) END OBJ(mpd_bitrate,
- INFO_MPD)
- END OBJ(mpd_status, INFO_MPD)
- END OBJ(mpd_bar, INFO_MPD)
- (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ OBJ(mpd_artist, INFO_MPD)
+ END OBJ(mpd_title, INFO_MPD)
+ END OBJ(mpd_random, INFO_MPD)
+ END OBJ(mpd_repeat, INFO_MPD)
+ END OBJ(mpd_elapsed, INFO_MPD)
+ END OBJ(mpd_length, INFO_MPD)
+ END OBJ(mpd_track, INFO_MPD)
+ END OBJ(mpd_name, INFO_MPD)
+ END OBJ(mpd_file, INFO_MPD)
+ END OBJ(mpd_percent, INFO_MPD)
+ END OBJ(mpd_album, INFO_MPD)
+ END OBJ(mpd_vol, INFO_MPD)
+ END OBJ(mpd_bitrate, INFO_MPD)
+ END OBJ(mpd_status, INFO_MPD)
+ END OBJ(mpd_bar, INFO_MPD)
+ (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ END OBJ(mpd_smart, INFO_MPD) END
+#endif
+#ifdef XMMS2
+ OBJ(xmms2_artist, INFO_XMMS2)
+ END OBJ(xmms2_album, INFO_XMMS2)
+ END OBJ(xmms2_title, INFO_XMMS2)
+ END OBJ(xmms2_genre, INFO_XMMS2)
+ END OBJ(xmms2_comment, INFO_XMMS2)
+ END OBJ(xmms2_decoder, INFO_XMMS2)
+ END OBJ(xmms2_transport, INFO_XMMS2)
+ END OBJ(xmms2_url, INFO_XMMS2)
+ END OBJ(xmms2_tracknr, INFO_XMMS2)
+ END OBJ(xmms2_bitrate, INFO_XMMS2)
+ END OBJ(xmms2_date, INFO_XMMS2)
+ END OBJ(xmms2_id, INFO_XMMS2)
+ END OBJ(xmms2_duration, INFO_XMMS2)
+ END OBJ(xmms2_elapsed, INFO_XMMS2)
+ END OBJ(xmms2_size, INFO_XMMS2)
+ END OBJ(xmms2_status, INFO_XMMS2)
+ END OBJ(xmms2_percent, INFO_XMMS2)
+ END OBJ(xmms2_bar, INFO_XMMS2)
+ (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ END OBJ(xmms2_smart, INFO_XMMS2)
+ END
+#endif
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ OBJ(xmms_status, INFO_XMMS) END
+ OBJ(xmms_title, INFO_XMMS) END
+ OBJ(xmms_length, INFO_XMMS) END
+ OBJ(xmms_length_seconds, INFO_XMMS) END
+ OBJ(xmms_position, INFO_XMMS) END
+ OBJ(xmms_position_seconds, INFO_XMMS) END
+ OBJ(xmms_bitrate, INFO_XMMS) END
+ OBJ(xmms_frequency, INFO_XMMS) END
+ OBJ(xmms_channels, INFO_XMMS) END
+ OBJ(xmms_filename, INFO_XMMS) END
+ OBJ(xmms_playlist_length, INFO_XMMS) END
+ OBJ(xmms_playlist_position, INFO_XMMS) END
+ OBJ(xmms_bar, INFO_XMMS)
+ (void) scan_bar(arg, &obj->a, &obj->b);
END
#endif
#ifdef BMPX
- OBJ(bmpx_title, INFO_BMPX)
+ OBJ(bmpx_title, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
END
- OBJ(bmpx_artist, INFO_BMPX)
+ OBJ(bmpx_artist, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
END
- OBJ(bmpx_album, INFO_BMPX)
+ OBJ(bmpx_album, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
END
- OBJ(bmpx_track, INFO_BMPX)
+ OBJ(bmpx_track, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
END
- OBJ(bmpx_uri, INFO_BMPX)
+ OBJ(bmpx_uri, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
END
- OBJ(bmpx_bitrate, INFO_BMPX)
+ OBJ(bmpx_bitrate, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
END
#endif
-#ifdef INFOPIPE
- OBJ(infopipe_protocol, INFO_INFOPIPE) END
- OBJ(infopipe_version, INFO_INFOPIPE) END
- OBJ(infopipe_status, INFO_INFOPIPE) END
- OBJ(infopipe_playlist_tunes, INFO_INFOPIPE) END
- OBJ(infopipe_playlist_currtune, INFO_INFOPIPE) END
- OBJ(infopipe_usec_position, INFO_INFOPIPE) END
- OBJ(infopipe_position, INFO_INFOPIPE) END
- OBJ(infopipe_usec_time, INFO_INFOPIPE) END
- OBJ(infopipe_time, INFO_INFOPIPE) END
- OBJ(infopipe_bitrate, INFO_INFOPIPE) END
- OBJ(infopipe_frequency, INFO_INFOPIPE) END
- OBJ(infopipe_channels, INFO_INFOPIPE) END
- OBJ(infopipe_title, INFO_INFOPIPE) END
- OBJ(infopipe_file, INFO_INFOPIPE) END
- OBJ(infopipe_bar, INFO_INFOPIPE)
- (void) scan_bar(arg, &obj->a, &obj->b);
+#ifdef HDDTEMP
+ OBJ(hddtemp, 0)
+ if (!arg || scan_hddtemp(arg, &obj->data.hddtemp.dev,
+ &obj->data.hddtemp.addr, &obj->data.hddtemp.port)) {
+ ERR("hddtemp needs arguments");
+ obj->type = OBJ_text;
+ obj->data.s = strdup("${hddtemp}");
+ return NULL;
+ }
END
#endif
#ifdef TCP_PORT_MONITOR
- OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR)
+ OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR)
int argc, port_begin, port_end, item, connection_index;
- char itembuf[32];
- memset(itembuf,0,sizeof(itembuf));
- connection_index=0;
- /* massive argument checking */
- if (!arg) {
- CRIT_ERR("tcp_portmon: needs arguments");
- }
- argc=sscanf(arg, "%d %d %31s %d", &port_begin, &port_end, itembuf, &connection_index);
- if ( (argc != 3) && (argc != 4) )
- {
- CRIT_ERR("tcp_portmon: requires 3 or 4 arguments");
- }
- if ( (port_begin<1) || (port_begin>65535) || (port_end<1) || (port_end>65535) )
- {
- CRIT_ERR("tcp_portmon: port values must be from 1 to 65535");
- }
- if ( port_begin > port_end )
- {
- CRIT_ERR("tcp_portmon: starting port must be <= ending port");
- }
- if ( strncmp(itembuf,"count",31) == 0 )
- item=COUNT;
- else if ( strncmp(itembuf,"rip",31) == 0 )
- item=REMOTEIP;
- else if ( strncmp(itembuf,"rhost",31) == 0 )
- item=REMOTEHOST;
- else if ( strncmp(itembuf,"rport",31) == 0 )
- item=REMOTEPORT;
- else if ( strncmp(itembuf,"lip",31) == 0 )
- item=LOCALIP;
- else if ( strncmp(itembuf,"lhost",31) == 0 )
- item=LOCALHOST;
- else if ( strncmp(itembuf,"lport",31) == 0 )
- item=LOCALPORT;
- else if ( strncmp(itembuf,"lservice",31) == 0 )
- item=LOCALSERVICE;
- else
- {
- CRIT_ERR("tcp_portmon: invalid item specified");
- }
- if ( (argc==3) && (item!=COUNT) )
- {
- CRIT_ERR("tcp_portmon: 3 argument form valid only for \"count\" item");
- }
- if ( (argc==4) && (connection_index<0) )
+ char itembuf[32];
+ memset(itembuf,0,sizeof(itembuf));
+ connection_index=0;
+ /* massive argument checking */
+ if (!arg) {
+ CRIT_ERR("tcp_portmon: needs arguments");
+ }
+ argc=sscanf(arg, "%d %d %31s %d", &port_begin, &port_end, itembuf, &connection_index);
+ if ( (argc != 3) && (argc != 4) )
+ {
+ CRIT_ERR("tcp_portmon: requires 3 or 4 arguments");
+ }
+ if ( (port_begin<1) || (port_begin>65535) || (port_end<1) || (port_end>65535) )
+ {
+ CRIT_ERR("tcp_portmon: port values must be from 1 to 65535");
+ }
+ if ( port_begin > port_end )
+ {
+ CRIT_ERR("tcp_portmon: starting port must be <= ending port");
+ }
+ if ( strncmp(itembuf,"count",31) == 0 )
+ item=COUNT;
+ else if ( strncmp(itembuf,"rip",31) == 0 )
+ item=REMOTEIP;
+ else if ( strncmp(itembuf,"rhost",31) == 0 )
+ item=REMOTEHOST;
+ else if ( strncmp(itembuf,"rport",31) == 0 )
+ item=REMOTEPORT;
+ else if ( strncmp(itembuf,"rservice",31) == 0 )
+ item=REMOTESERVICE;
+ else if ( strncmp(itembuf,"lip",31) == 0 )
+ item=LOCALIP;
+ else if ( strncmp(itembuf,"lhost",31) == 0 )
+ item=LOCALHOST;
+ else if ( strncmp(itembuf,"lport",31) == 0 )
+ item=LOCALPORT;
+ else if ( strncmp(itembuf,"lservice",31) == 0 )
+ item=LOCALSERVICE;
+ else
+ {
+ CRIT_ERR("tcp_portmon: invalid item specified");
+ }
+ if ( (argc==3) && (item!=COUNT) )
+ {
+ CRIT_ERR("tcp_portmon: 3 argument form valid only for \"count\" item");
+ }
+ if ( (argc==4) && (connection_index<0) )
+ {
+ CRIT_ERR("tcp_portmon: connection index must be non-negative");
+ }
+ /* ok, args looks good. save the text object data */
+ obj->data.tcp_port_monitor.port_range_begin = (in_port_t)port_begin;
+ obj->data.tcp_port_monitor.port_range_end = (in_port_t)port_end;
+ obj->data.tcp_port_monitor.item = item;
+ obj->data.tcp_port_monitor.connection_index = connection_index;
+
+ /* if the port monitor collection hasn't been created, we must create it */
+ if ( !info.p_tcp_port_monitor_collection )
+ {
+ info.p_tcp_port_monitor_collection =
+ create_tcp_port_monitor_collection( &tcp_port_monitor_collection_args );
+ if ( !info.p_tcp_port_monitor_collection )
{
- CRIT_ERR("tcp_portmon: connection index must be non-negative");
+ CRIT_ERR("tcp_portmon: unable to create port monitor collection");
}
- /* ok, args looks good. save the text object data */
- obj->data.tcp_port_monitor.port_range_begin = (in_addr_t)port_begin;
- obj->data.tcp_port_monitor.port_range_end = (in_addr_t)port_end;
- obj->data.tcp_port_monitor.item = item;
- obj->data.tcp_port_monitor.connection_index = connection_index;
+ }
- /* if the port monitor collection hasn't been created, we must create it */
- if ( !info.p_tcp_port_monitor_collection )
+ /* if a port monitor for this port does not exist, create one and add it to the collection */
+ if ( find_tcp_port_monitor( info.p_tcp_port_monitor_collection, port_begin, port_end ) == NULL )
+ {
+ tcp_port_monitor_t * p_monitor =
+ create_tcp_port_monitor( port_begin, port_end, &tcp_port_monitor_args );
+ if ( !p_monitor )
{
- info.p_tcp_port_monitor_collection =
- create_tcp_port_monitor_collection( &tcp_port_monitor_collection_args );
- if ( !info.p_tcp_port_monitor_collection )
- {
- CRIT_ERR("tcp_portmon: unable to create port monitor collection");
- }
+ CRIT_ERR("tcp_portmon: unable to create port monitor");
}
-
- /* if a port monitor for this port does not exist, create one and add it to the collection */
- if ( find_tcp_port_monitor( info.p_tcp_port_monitor_collection, port_begin, port_end ) == NULL )
+ /* add the newly created monitor to the collection */
+ if ( insert_tcp_port_monitor_into_collection( info.p_tcp_port_monitor_collection,
+ p_monitor ) != 0 )
{
- tcp_port_monitor_t * p_monitor =
- create_tcp_port_monitor( port_begin, port_end, &tcp_port_monitor_args );
- if ( !p_monitor )
- {
- CRIT_ERR("tcp_portmon: unable to create port monitor");
- }
- /* add the newly created monitor to the collection */
- if ( insert_tcp_port_monitor_into_collection( info.p_tcp_port_monitor_collection,
- p_monitor ) != 0 )
- {
- CRIT_ERR("tcp_portmon: unable to add port monitor to collection");
- }
+ CRIT_ERR("tcp_portmon: unable to add port monitor to collection");
}
+ }
END
#endif
{
static struct text_object *create_plain_text(const char *s)
{
- struct text_object *obj;
+ struct text_object *obj;
- if (s == NULL || *s == '\0') {
- return NULL;
- }
-
- obj = new_text_object_internal();
+ if (s == NULL || *s == '\0') {
+ return NULL;
+ }
- obj->type = OBJ_text;
- obj->data.s = strdup(s);
- return obj;
+ obj = new_text_object_internal();
+
+ obj->type = OBJ_text;
+ obj->data.s = strdup(s);
+ return obj;
}
static struct text_object_list *extract_variable_text_internal(const char *p)
{
- struct text_object_list *retval;
- struct text_object *obj;
- const char *s = p;
-
- retval = malloc(sizeof(struct text_object_list));
- memset(retval, 0, sizeof(struct text_object_list));
- retval->text_object_count = 0;
-
+ struct text_object_list *retval;
+ struct text_object *obj;
+ const char *s = p;
+
+ retval = malloc(sizeof(struct text_object_list));
+ memset(retval, 0, sizeof(struct text_object_list));
+ retval->text_object_count = 0;
+
+ long line = text_lines;
+
while (*p) {
+ if (*p == '\n') {
+ line++;
+ }
if (*p == '$') {
*(char *) p = '\0';
obj = create_plain_text(s);
if(obj != NULL) {
- // allocate memory for the object
- retval->text_objects = realloc(retval->text_objects,
- sizeof(struct text_object) * (retval->text_object_count+1));
- // assign the new object to the end of the list.
- memcpy(&retval->text_objects[retval->text_object_count++],
- obj, sizeof(struct text_object));
- free(obj);
+ // allocate memory for the object
+ retval->text_objects = realloc(retval->text_objects,
+ sizeof(struct text_object) * (retval->text_object_count+1));
+ // assign the new object to the end of the list.
+ memcpy(&retval->text_objects[retval->text_object_count++],
+ obj, sizeof(struct text_object));
+ free(obj);
}
*(char *) p = '$';
p++;
if (*p == '#')
p++;
while (*p && (isalnum((int) *p)
- || *p == '_'))
+ || *p == '_'))
p++;
}
}
// create new object
- obj = construct_text_object(buf, arg);
+ obj = construct_text_object(buf, arg, retval->text_object_count, retval->text_objects, line);
if(obj != NULL) {
- // allocate memory for the object
- retval->text_objects = realloc(retval->text_objects,
- sizeof(struct text_object) * (retval->text_object_count+1));
- // assign the new object to the end of the list.
- memcpy(&retval->text_objects[retval->text_object_count++],
- obj, sizeof(struct text_object));
- free(obj);
+ // allocate memory for the object
+ retval->text_objects = realloc(retval->text_objects,
+ sizeof(struct text_object) * (retval->text_object_count+1));
+ // assign the new object to the end of the list.
+ memcpy(&retval->text_objects[retval->text_object_count++],
+ obj, sizeof(struct text_object));
+ free(obj);
}
}
continue;
} else {
- obj = create_plain_text("$");
- if(obj != NULL) {
- // allocate memory for the object
- retval->text_objects = realloc(retval->text_objects,
- sizeof(struct text_object) * (retval->text_object_count+1));
- // assign the new object to the end of the list.
- memcpy(&retval->text_objects[retval->text_object_count++],
- obj, sizeof(struct text_object));
- free(obj);
- }
+ obj = create_plain_text("$");
+ if(obj != NULL) {
+ // allocate memory for the object
+ retval->text_objects = realloc(retval->text_objects,
+ sizeof(struct text_object) * (retval->text_object_count+1));
+ // assign the new object to the end of the list.
+ memcpy(&retval->text_objects[retval->text_object_count++],
+ obj, sizeof(struct text_object));
+ free(obj);
+ }
}
}
p++;
}
obj = create_plain_text(s);
if(obj != NULL) {
- // allocate memory for the object
- retval->text_objects = realloc(retval->text_objects,
- sizeof(struct text_object) * (retval->text_object_count+1));
- // assign the new object to the end of the list.
- memcpy(&retval->text_objects[retval->text_object_count++],
- obj, sizeof(struct text_object));
- free(obj);
+ // allocate memory for the object
+ retval->text_objects = realloc(retval->text_objects,
+ sizeof(struct text_object) * (retval->text_object_count+1));
+ // assign the new object to the end of the list.
+ memcpy(&retval->text_objects[retval->text_object_count++],
+ obj, sizeof(struct text_object));
+ free(obj);
}
if (blockdepth) {
static void extract_variable_text(const char *p)
{
- struct text_object_list *list;
+ struct text_object_list *list;
- free_text_objects(text_object_count, text_objects);
- text_object_count = 0;
- text_objects = NULL;
+ free_text_objects(text_object_count, text_objects);
+ text_object_count = 0;
+ text_objects = NULL;
#ifdef MLDONKEY
- ml_cleanup();
+ ml_cleanup();
#endif /* MLDONKEY */
-
- list = extract_variable_text_internal(p);
- text_objects = list->text_objects;
- text_object_count = list->text_object_count;
- free(list);
- return;
+ list = extract_variable_text_internal(p);
+ text_objects = list->text_objects;
+ text_object_count = list->text_object_count;
+
+ free(list);
+
+ return;
}
void parse_conky_vars(char * text, char * p, struct information *cur) {
static void generate_text_internal(char *p, int p_max_size, struct text_object *objs, unsigned int object_count, struct information *cur)
{
- unsigned int i;
+ unsigned int i;
+
+#ifdef HAVE_ICONV
+ char buff_in[P_MAX_SIZE] = {0};
+ iconv_converting = 0;
+#endif
for (i = 0; i < object_count; i++) {
struct text_object *obj = &objs[i];
#define OBJ(a) break; case OBJ_##a:
switch (obj->type) {
- default:
- {
- ERR("not implemented obj type %d",
- obj->type);
- }
- OBJ(acpitemp) {
- /* does anyone have decimals in acpi temperature? */
- if (!use_spacer)
- snprintf(p, p_max_size, "%d", (int)
- get_acpi_temperature(obj->
+ default:
+ {
+ ERR("not implemented obj type %d",
+ obj->type);
+ }
+ OBJ(acpitemp) {
+ /* does anyone have decimals in acpi temperature? */
+ if (!use_spacer)
+ snprintf(p, p_max_size, "%d", (int)
+ get_acpi_temperature(obj->
data.
i));
- else
- snprintf(p, 5, "%d ", (int)
- get_acpi_temperature(obj->
+ else
+ snprintf(p, 5, "%d ", (int)
+ get_acpi_temperature(obj->
data.
i));
- }
- OBJ(acpitempf) {
- /* does anyone have decimals in acpi temperature? */
- if (!use_spacer)
- snprintf(p, p_max_size, "%d", (int)
- ((get_acpi_temperature(obj->
- data.
- i)+ 40) * 9.0 / 5 - 40));
- else
- snprintf(p, 5, "%d ", (int)
- ((get_acpi_temperature(obj->
- data.
- i)+ 40) * 9.0 / 5 - 40));
- }
- OBJ(freq) {
- get_freq(p, p_max_size, "%.0f", 1); /* pk */
- }
- OBJ(freq_g) {
- get_freq(p, p_max_size, "%'.2f", 1000); /* pk */
- }
- OBJ(freq_dyn) {
- if (use_spacer) {
- get_freq_dynamic(p, 6, "%.0f ", 1 ); /* pk */
- } else {
- get_freq_dynamic(p, p_max_size, "%.0f", 1 ); /* pk */
}
- }
- OBJ(freq_dyn_g) {
- if (use_spacer) {
- get_freq_dynamic(p, 6, "%'.2f ", 1000); /* pk */
- } else {
- get_freq_dynamic(p, p_max_size, "%'.2f", 1000); /* pk */
+ OBJ(acpitempf) {
+ /* does anyone have decimals in acpi temperature? */
+ if (!use_spacer)
+ snprintf(p, p_max_size, "%d", (int)
+ ((get_acpi_temperature(obj->
+ data.
+ i)+ 40) * 9.0 / 5 - 40));
+ else
+ snprintf(p, 5, "%d ", (int)
+ ((get_acpi_temperature(obj->
+ data.
+ i)+ 40) * 9.0 / 5 - 40));
+ }
+ OBJ(freq) {
+ if (obj->a) {
+ obj->a = get_freq(p, p_max_size, "%.0f", 1, obj->data.cpu_index); /* pk */
+ }
+ }
+ OBJ(freq_g) {
+ if (obj->a) {
+ obj->a = get_freq(p, p_max_size, "%'.2f", 1000, obj->data.cpu_index); /* pk */
+ }
+ }
+#if defined(__linux__)
+ OBJ(voltage_mv) {
+ if (obj->a) {
+ obj->a = get_voltage(p, p_max_size, "%.0f", 1, obj->data.cpu_index);
+ }
+ }
+ OBJ(voltage_v) {
+ if (obj->a) {
+ obj->a = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.cpu_index);
+ }
+ }
+#endif /* __linux__ */
+
+ OBJ(freq_dyn) {
+ if (use_spacer) {
+ get_freq_dynamic(p, 6, "%.0f ", 1 ); /* pk */
+ } else {
+ get_freq_dynamic(p, p_max_size, "%.0f", 1 ); /* pk */
+ }
+ }
+ OBJ(freq_dyn_g) {
+ if (use_spacer) {
+ get_freq_dynamic(p, 6, "%'.2f ", 1000); /* pk */
+ } else {
+ get_freq_dynamic(p, p_max_size, "%'.2f", 1000); /* pk */
+ }
+ }
+ OBJ(adt746xcpu) {
+ get_adt746x_cpu(p, p_max_size); /* pk */
}
- }
- OBJ(adt746xcpu) {
- get_adt746x_cpu(p, p_max_size); /* pk */
- }
- OBJ(adt746xfan) {
- get_adt746x_fan(p, p_max_size); /* pk */
- }
- OBJ(acpifan) {
- get_acpi_fan(p, p_max_size); /* pk */
- }
- OBJ(acpiacadapter) {
- get_acpi_ac_adapter(p, p_max_size); /* pk */
- }
- OBJ(battery) {
- get_battery_stuff(p, p_max_size, obj->data.s);
- }
- OBJ(buffers) {
- human_readable(cur->buffers * 1024, p, 255);
- }
- OBJ(cached) {
- human_readable(cur->cached * 1024, p, 255);
- }
- OBJ(cpu) {
- if (obj->data.cpu_index > info.cpu_count) {
- printf("obj->data.cpu_index %i info.cpu_count %i", obj->data.cpu_index, info.cpu_count);
- CRIT_ERR("attempting to use more CPUs then you have!");
+ OBJ(adt746xfan) {
+ get_adt746x_fan(p, p_max_size); /* pk */
+ }
+ OBJ(acpifan) {
+ get_acpi_fan(p, p_max_size); /* pk */
+ }
+ OBJ(acpiacadapter) {
+ get_acpi_ac_adapter(p, p_max_size); /* pk */
+ }
+ OBJ(battery) {
+ get_battery_stuff(p, p_max_size, obj->data.s);
+ }
+ OBJ(buffers) {
+ human_readable(cur->buffers * 1024, p, 255);
+ }
+ OBJ(cached) {
+ human_readable(cur->cached * 1024, p, 255);
+ }
+ OBJ(cpu) {
+ if (obj->data.cpu_index > info.cpu_count) {
+ printf("obj->data.cpu_index %i info.cpu_count %i", obj->data.cpu_index, info.cpu_count);
+ CRIT_ERR("attempting to use more CPUs then you have!");
+ }
+ if (!use_spacer)
+ snprintf(p, p_max_size, "%*d", pad_percents,
+ (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
+ 100.0));
+ else
+ snprintf(p, 4, "%*d ",
+ pad_percents,
+ (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
+ 100.0));
+ }
+ OBJ(cpubar) {
+ new_bar(p, obj->a,
+ obj->b,
+ (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
+ }
+ OBJ(cpugraph) {
+ new_graph(p, obj->a,
+ obj->b, obj->c, obj->d,
+ (unsigned int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
+ 100), 100, 1);
+ }
+ OBJ(color) {
+ new_fg(p, obj->data.l);
}
- if (!use_spacer)
- snprintf(p, p_max_size, "%*d", pad_percents,
- (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
- 100.0));
- else
- snprintf(p, 4, "%*d ",
- pad_percents,
- (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
- 100.0));
- }
- OBJ(cpubar) {
- new_bar(p, obj->a,
- obj->b,
- (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
- }
- OBJ(cpugraph) {
- new_graph(p, obj->a,
- obj->b, obj->c, obj->d,
- (unsigned int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
- 100), 100, 1);
- }
- OBJ(color) {
- new_fg(p, obj->data.l);
- }
#if defined(__linux__)
- OBJ(i8k_version) {
- snprintf(p, p_max_size, "%s", i8k.version);
- }
- OBJ(i8k_bios) {
- snprintf(p, p_max_size, "%s", i8k.bios);
- }
- OBJ(i8k_serial) {
- snprintf(p, p_max_size, "%s", i8k.serial);
- }
- OBJ(i8k_cpu_temp) {
- snprintf(p, p_max_size, "%s", i8k.cpu_temp);
- }
- OBJ(i8k_cpu_tempf) {
- int cpu_temp;
- sscanf(i8k.cpu_temp, "%d", &cpu_temp);
- snprintf(p, p_max_size, "%.1f", cpu_temp*(9.0/5.0)+32.0);
- }
- OBJ(i8k_left_fan_status) {
- int left_fan_status;
- sscanf(i8k.left_fan_status, "%d", &left_fan_status);
- if(left_fan_status == 0) {
- snprintf(p, p_max_size,"off");
- } if(left_fan_status == 1) {
- snprintf(p, p_max_size, "low");
- } if(left_fan_status == 2) {
- snprintf(p, p_max_size, "high");
+ OBJ(i8k_version) {
+ snprintf(p, p_max_size, "%s", i8k.version);
+ }
+ OBJ(i8k_bios) {
+ snprintf(p, p_max_size, "%s", i8k.bios);
}
+ OBJ(i8k_serial) {
+ snprintf(p, p_max_size, "%s", i8k.serial);
+ }
+ OBJ(i8k_cpu_temp) {
+ snprintf(p, p_max_size, "%s", i8k.cpu_temp);
+ }
+ OBJ(i8k_cpu_tempf) {
+ int cpu_temp;
+ sscanf(i8k.cpu_temp, "%d", &cpu_temp);
+ snprintf(p, p_max_size, "%.1f", cpu_temp*(9.0/5.0)+32.0);
+ }
+ OBJ(i8k_left_fan_status) {
+ int left_fan_status;
+ sscanf(i8k.left_fan_status, "%d", &left_fan_status);
+ if(left_fan_status == 0) {
+ snprintf(p, p_max_size,"off");
+ } if(left_fan_status == 1) {
+ snprintf(p, p_max_size, "low");
+ } if(left_fan_status == 2) {
+ snprintf(p, p_max_size, "high");
+ }
- }
- OBJ(i8k_right_fan_status) {
- int right_fan_status;
- sscanf(i8k.right_fan_status, "%d", &right_fan_status);
- if(right_fan_status == 0) {
- snprintf(p, p_max_size,"off");
- } if(right_fan_status == 1) {
- snprintf(p, p_max_size, "low");
- } if(right_fan_status == 2) {
- snprintf(p, p_max_size, "high");
}
- }
- OBJ(i8k_left_fan_rpm) {
- snprintf(p, p_max_size, "%s", i8k.left_fan_rpm);
- }
- OBJ(i8k_right_fan_rpm) {
- snprintf(p, p_max_size, "%s", i8k.right_fan_rpm);
- }
- OBJ(i8k_ac_status) {
- int ac_status;
- sscanf(i8k.ac_status, "%d", &ac_status);
- if(ac_status == -1) {
- snprintf(p, p_max_size,"disabled (read i8k docs)");
- } if(ac_status == 0) {
- snprintf(p, p_max_size, "off");
- } if(ac_status == 1) {
- snprintf(p, p_max_size, "on");
+ OBJ(i8k_right_fan_status) {
+ int right_fan_status;
+ sscanf(i8k.right_fan_status, "%d", &right_fan_status);
+ if(right_fan_status == 0) {
+ snprintf(p, p_max_size,"off");
+ } if(right_fan_status == 1) {
+ snprintf(p, p_max_size, "low");
+ } if(right_fan_status == 2) {
+ snprintf(p, p_max_size, "high");
+ }
}
- }
- OBJ(i8k_buttons_status) {
- snprintf(p, p_max_size, "%s", i8k.buttons_status);
+ OBJ(i8k_left_fan_rpm) {
+ snprintf(p, p_max_size, "%s", i8k.left_fan_rpm);
+ }
+ OBJ(i8k_right_fan_rpm) {
+ snprintf(p, p_max_size, "%s", i8k.right_fan_rpm);
+ }
+ OBJ(i8k_ac_status) {
+ int ac_status;
+ sscanf(i8k.ac_status, "%d", &ac_status);
+ if(ac_status == -1) {
+ snprintf(p, p_max_size,"disabled (read i8k docs)");
+ } if(ac_status == 0) {
+ snprintf(p, p_max_size, "off");
+ } if(ac_status == 1) {
+ snprintf(p, p_max_size, "on");
+ }
+ }
+ OBJ(i8k_buttons_status) {
+ snprintf(p, p_max_size, "%s", i8k.buttons_status);
- }
+ }
+ OBJ(ibm_fan) {
+ get_ibm_acpi_fan(p, p_max_size);
+ }
+ OBJ(ibm_temps) {
+ get_ibm_acpi_temps();
+ snprintf(p, p_max_size, "%d",
+ ibm_acpi.temps[obj->data.sensor]);
+ }
+ OBJ(ibm_volume) {
+ get_ibm_acpi_volume(p, p_max_size);
+ }
+ OBJ(ibm_brightness) {
+ get_ibm_acpi_brightness(p, p_max_size);
+ }
+ OBJ(pb_battery) {
+ get_powerbook_batt_info(p, p_max_size, obj->data.i);
+ }
#endif /* __linux__ */
#ifdef X11
- OBJ(font) {
- new_font(p, obj->data.s);
- }
+ OBJ(font) {
+ new_font(p, obj->data.s);
+ }
#endif /* X11 */
- OBJ(diskio) {
- if (!use_spacer) {
- if (diskio_value > 1024*1024) {
- snprintf(p, p_max_size, "%.1fG",
- (double)diskio_value/1024/1024);
- } else if (diskio_value > 1024) {
- snprintf(p, p_max_size, "%.1fM",
- (double)diskio_value/1024);
- } else if (diskio_value > 0) {
- snprintf(p, p_max_size, "%dK", diskio_value);
+ OBJ(diskio) {
+ if (!use_spacer) {
+ if (diskio_value > 1024*1024) {
+ snprintf(p, p_max_size, "%.1fGiB",
+ (double)diskio_value/1024/1024);
+ } else if (diskio_value > 1024) {
+ snprintf(p, p_max_size, "%.1fMiB",
+ (double)diskio_value/1024);
+ } else if (diskio_value > 0) {
+ snprintf(p, p_max_size, "%dKiB", diskio_value);
+ } else {
+ snprintf(p, p_max_size, "%dB", diskio_value);
+ }
} else {
- snprintf(p, p_max_size, "%d", diskio_value);
+ if (diskio_value > 1024*1024) {
+ snprintf(p, 6, "%.1fGiB ",
+ (double)diskio_value/1024/1024);
+ } else if (diskio_value > 1024) {
+ snprintf(p, 6, "%.1fMiB ",
+ (double)diskio_value/1024);
+ } else if (diskio_value > 0) {
+ snprintf(p, 6, "%dKiB ", diskio_value);
+ } else {
+ snprintf(p, 6, "%dB ", diskio_value);
+ }
}
- } else {
- if (diskio_value > 1024*1024) {
- snprintf(p, 6, "%.1fG ",
- (double)diskio_value/1024/1024);
- } else if (diskio_value > 1024) {
- snprintf(p, 6, "%.1fM ",
- (double)diskio_value/1024);
- } else if (diskio_value > 0) {
- snprintf(p, 6, "%dK ", diskio_value);
+ }
+ OBJ(diskiograph) {
+ new_graph(p, obj->a,
+ obj->b, obj->c, obj->d,
+ diskio_value, obj->e, 1);
+ }
+
+ OBJ(downspeed) {
+ if (!use_spacer) {
+ snprintf(p, p_max_size, "%d",
+ (int) (obj->data.net->
+ recv_speed /
+ 1024));
+ } else
+ snprintf(p, 6, "%d ",
+ (int) (obj->data.net->
+ recv_speed /
+ 1024));
+ }
+ OBJ(downspeedf) {
+ if (!use_spacer)
+ snprintf(p, p_max_size, "%.1f",
+ obj->data.net->
+ recv_speed / 1024.0);
+ else
+ snprintf(p, 8, "%.1f ",
+ obj->data.net->
+ recv_speed / 1024.0);
+ }
+ OBJ(downspeedgraph) {
+ if (obj->data.net->recv_speed == 0) // this is just to make the ugliness at start go away
+ obj->data.net->recv_speed = 0.01;
+ new_graph(p, obj->a, obj->b, obj->c, obj->d,
+ (obj->data.net->recv_speed /
+ 1024.0), obj->e, 1);
+ }
+ OBJ(else) {
+ if (!if_jumped) {
+ i = obj->data.ifblock.pos - 1;
} else {
- snprintf(p, 6, "%d ", diskio_value);
+ if_jumped = 0;
}
}
- }
- OBJ(diskiograph) {
- new_graph(p, obj->a,
- obj->b, obj->c, obj->d,
- diskio_value, obj->e, 1);
- }
-
- OBJ(downspeed) {
- if (!use_spacer) {
- snprintf(p, p_max_size, "%d",
- (int) (obj->data.net->
- recv_speed /
- 1024));
- } else
- snprintf(p, 6, "%d ",
- (int) (obj->data.net->
- recv_speed /
- 1024));
- }
- OBJ(downspeedf) {
- if (!use_spacer)
- snprintf(p, p_max_size, "%.1f",
- obj->data.net->
- recv_speed / 1024.0);
- else
- snprintf(p, 8, "%.1f ",
- obj->data.net->
- recv_speed / 1024.0);
- }
- OBJ(downspeedgraph) {
- if (obj->data.net->recv_speed == 0) // this is just to make the ugliness at start go away
- obj->data.net->recv_speed = 0.01;
- new_graph(p, obj->a, obj->b, obj->c, obj->d,
- (obj->data.net->recv_speed /
- 1024.0), obj->e, 1);
- }
- OBJ(
- else
- ) {
- if (!if_jumped) {
- i = obj->data.ifblock.pos - 2;
- } else {
+ OBJ(endif) {
if_jumped = 0;
}
- }
- OBJ(endif) {
- if_jumped = 0;
- }
#ifdef HAVE_POPEN
- OBJ(addr) {
- snprintf(p, p_max_size, "%u.%u.%u.%u",
- obj->data.net->addr.
- sa_data[2] & 255,
- obj->data.net->addr.
- sa_data[3] & 255,
- obj->data.net->addr.
- sa_data[4] & 255,
- obj->data.net->addr.
- sa_data[5] & 255);
-
- }
- OBJ(linkstatus) {
- snprintf(p, p_max_size, "%d",
- obj->data.net->linkstatus);
- }
+ OBJ(addr) {
+ snprintf(p, p_max_size, "%u.%u.%u.%u",
+ obj->data.net->addr.
+ sa_data[2] & 255,
+ obj->data.net->addr.
+ sa_data[3] & 255,
+ obj->data.net->addr.
+ sa_data[4] & 255,
+ obj->data.net->addr.
+ sa_data[5] & 255);
- OBJ(exec) {
- FILE *fp = popen(obj->data.s, "r");
- int length = fread(p, 1, p_max_size, fp);
- (void) pclose(fp);
+ }
+ OBJ(linkstatus) {
+ snprintf(p, p_max_size, "%d",
+ obj->data.net->linkstatus);
+ }
+#if defined(IMLIB2) && defined(X11)
+ OBJ(image) {
+ if (obj->a < 1) {
+ obj->a++;
+ } else {
+ Imlib_Image image, buffer;
+ image = imlib_load_image(obj->data.s);
+ imlib_context_set_image(image);
+ if (image) {
+ int w, h;
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ buffer = imlib_create_image(w, h);
+ imlib_context_set_display(display);
+ imlib_context_set_drawable(window.drawable);
+ imlib_context_set_colormap(DefaultColormap(display, screen));
+ imlib_context_set_visual(DefaultVisual(display, screen));
+ imlib_context_set_image(buffer);
+ imlib_blend_image_onto_image(image, 0, 0, 0, w, h, text_start_x, text_start_y, w, h);
+ imlib_render_image_on_drawable(text_start_x, text_start_y);
+ imlib_free_image();
+ imlib_context_set_image(image);
+ imlib_free_image();
+ }
+ }
+ }
+#endif /* IMLIB2 */
+ OBJ(exec) {
+ FILE *fp = popen(obj->data.s, "r");
+ int length = fread(p, 1, p_max_size, fp);
+ (void) pclose(fp);
- /*output[length] = '\0';
- if (length > 0 && output[length - 1] == '\n') {
- output[length - 1] = '\0';
- }*/
+ /*output[length] = '\0';
+ if (length > 0 && output[length - 1] == '\n') {
+ output[length - 1] = '\0';
+ }*/
p[length] = '\0';
if (length > 0 && p[length - 1] == '\n') {
p[length - 1] = '\0';
}
-
- //parse_conky_vars(output, p, cur);
- }
- OBJ(execbar) {
- char *p2 = p;
- FILE *fp = popen(obj->data.s, "r");
- int n2 = fread(p, 1, p_max_size, fp);
- (void) pclose(fp);
-
- p[n2] = '\0';
- if (n2 && p[n2 - 1] == '\n')
- p[n2 - 1] = '\0';
-
- while (*p2) {
- if (*p2 == '\001')
- *p2 = ' ';
- p2++;
- }
- double barnum;
- if (sscanf(p, "%lf", &barnum) == 0) {
- ERR("reading execbar value failed (perhaps it's not the correct format?)");
- }
- if (barnum > 100 || barnum < 0) {
- ERR("your execbar value is not between 0 and 100, therefore it will be ignored");
- } else {
- barnum = barnum / 100.0;
- new_bar(p, 0, 4, (int) (barnum * 255.0));
- }
-
- }
- OBJ(execgraph) {
- char *p2 = p;
- FILE *fp = popen(obj->data.s, "r");
- int n2 = fread(p, 1, p_max_size, fp);
- (void) pclose(fp);
-
- p[n2] = '\0';
- if (n2 && p[n2 - 1] == '\n')
- p[n2 - 1] = '\0';
- while (*p2) {
- if (*p2 == '\001')
- *p2 = ' ';
- p2++;
+ //parse_conky_vars(output, p, cur);
}
- double barnum;
- if (sscanf(p, "%lf", &barnum) == 0) {
- ERR("reading execgraph value failed (perhaps it's not the correct format?)");
- }
- if (barnum > 100 || barnum < 0) {
- ERR("your execgraph value is not between 0 and 100, therefore it will be ignored");
- } else {
- new_graph(p, 0,
- 25, obj->c, obj->d, (int) (barnum), obj->e, 1);
- }
-
- }
- OBJ(execibar) {
- if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
- new_bar(p, 0, 4, (int) obj->f);
- } else {
+ OBJ(execbar) {
char *p2 = p;
- FILE *fp = popen(obj->data.execi.cmd, "r");
+ FILE *fp = popen(obj->data.s, "r");
int n2 = fread(p, 1, p_max_size, fp);
(void) pclose(fp);
+
p[n2] = '\0';
if (n2 && p[n2 - 1] == '\n')
p[n2 - 1] = '\0';
*p2 = ' ';
p2++;
}
- float barnum;
- if (sscanf(p, "%f", &barnum) == 0) {
- ERR("reading execibar value failed (perhaps it's not the correct format?)");
+ double barnum;
+ if (sscanf(p, "%lf", &barnum) == 0) {
+ ERR("reading execbar value failed (perhaps it's not the correct format?)");
}
if (barnum > 100 || barnum < 0) {
- ERR("your execibar value is not between 0 and 100, therefore it will be ignored");
+ ERR("your execbar value is not between 0 and 100, therefore it will be ignored");
} else {
- obj->f = 255 * barnum / 100.0;
- new_bar(p, 0, 4, (int) obj->f);
+ barnum = barnum / 100.0;
+ new_bar(p, 0, 4, (int) (barnum * 255.0));
}
- obj->data.execi.last_update =
- current_update_time;
+
}
- }
- OBJ(execigraph) {
- if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
- new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
- } else {
+ OBJ(execgraph) {
char *p2 = p;
- FILE *fp = popen(obj->data.execi.cmd, "r");
+ FILE *fp = popen(obj->data.s, "r");
int n2 = fread(p, 1, p_max_size, fp);
(void) pclose(fp);
+
p[n2] = '\0';
if (n2 && p[n2 - 1] == '\n')
p[n2 - 1] = '\0';
*p2 = ' ';
p2++;
}
- float barnum;
- if (sscanf(p, "%f", &barnum) == 0) {
- ERR("reading execigraph value failed (perhaps it's not the correct format?)");
+ double barnum;
+ if (sscanf(p, "%lf", &barnum) == 0) {
+ ERR("reading execgraph value failed (perhaps it's not the correct format?)");
}
if (barnum > 100 || barnum < 0) {
- ERR("your execigraph value is not between 0 and 100, therefore it will be ignored");
+ ERR("your execgraph value is not between 0 and 100, therefore it will be ignored");
} else {
- obj->f = barnum;
- new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 1);
+ new_graph(p, 0, 25, obj->c, obj->d, (int) (barnum), obj->e, 1);
+ }
+
+ }
+ OBJ(execibar) {
+ if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+ new_bar(p, 0, 4, (int) obj->f);
+ } else {
+ char *p2 = p;
+ FILE *fp = popen(obj->data.execi.cmd, "r");
+ int n2 = fread(p, 1, p_max_size, fp);
+ (void) pclose(fp);
+ p[n2] = '\0';
+ if (n2 && p[n2 - 1] == '\n')
+ p[n2 - 1] = '\0';
+
+ while (*p2) {
+ if (*p2 == '\001')
+ *p2 = ' ';
+ p2++;
+ }
+ float barnum;
+ if (sscanf(p, "%f", &barnum) == 0) {
+ ERR("reading execibar value failed (perhaps it's not the correct format?)");
+ }
+ if (barnum > 100 || barnum < 0) {
+ ERR("your execibar value is not between 0 and 100, therefore it will be ignored");
+ } else {
+ obj->f = 255 * barnum / 100.0;
+ new_bar(p, 0, 4, (int) obj->f);
+ }
+ obj->data.execi.last_update =
+ current_update_time;
}
- obj->data.execi.last_update = current_update_time;
-
}
+ OBJ(execigraph) {
+ if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+ new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
+ } else {
+ char *p2 = p;
+ FILE *fp = popen(obj->data.execi.cmd, "r");
+ int n2 = fread(p, 1, p_max_size, fp);
+ (void) pclose(fp);
+ p[n2] = '\0';
+ if (n2 && p[n2 - 1] == '\n')
+ p[n2 - 1] = '\0';
+
+ while (*p2) {
+ if (*p2 == '\001')
+ *p2 = ' ';
+ p2++;
+ }
+ float barnum;
+ if (sscanf(p, "%f", &barnum) == 0) {
+ ERR("reading execigraph value failed (perhaps it's not the correct format?)");
+ }
+ if (barnum > 100 || barnum < 0) {
+ ERR("your execigraph value is not between 0 and 100, therefore it will be ignored");
+ } else {
+ obj->f = barnum;
+ new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 1);
+ }
+ obj->data.execi.last_update = current_update_time;
- }
- OBJ(execi) {
- if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval || obj->data.execi.interval == 0) {
- snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
- } else {
- char *output = obj->data.execi.buffer;
- FILE *fp = popen(obj->data.execi.cmd, "r");
- //int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
- int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
- (void) pclose(fp);
-
- output[length] = '\0';
- if (length > 0 && output[length - 1] == '\n') {
- output[length - 1] = '\0';
}
- obj->data.execi.last_update = current_update_time;
- snprintf(p, p_max_size, "%s", output);
+
}
- //parse_conky_vars(output, p, cur);
- }
- OBJ(texeci) {
- static int running = 0;
- if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
- snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
- } else {
- static pthread_t execthread;
- if (running) {
- pthread_join( execthread, NULL);
- running = 0;
+ OBJ(execi) {
+ if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval || obj->data.execi.interval == 0) {
+ snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
+ } else {
+ char *output = obj->data.execi.buffer;
+ FILE *fp = popen(obj->data.execi.cmd, "r");
+ //int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
+ int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
+ (void) pclose(fp);
+
+ output[length] = '\0';
+ if (length > 0 && output[length - 1] == '\n') {
+ output[length - 1] = '\0';
+ }
+ obj->data.execi.last_update = current_update_time;
+ snprintf(p, p_max_size, "%s", output);
}
- if (!running) {
- running = 1;
- pthread_create( &execthread, NULL, (void*)threaded_exec, (void*) obj);
- pthread_mutex_lock( &mutex1 );
+ //parse_conky_vars(output, p, cur);
+ }
+ OBJ(texeci) {
+ if (obj->data.execi.pos < 0) {
obj->data.execi.last_update = current_update_time;
- pthread_mutex_unlock( &mutex1 );
+ if (pthread_create(&(obj->data.execi.thread_info.thread), NULL, (void*)threaded_exec, (void*) obj)) {
+ ERR("Error starting thread");
+ }
+ obj->data.execi.pos = register_thread(&(obj->data.execi.thread_info));
}
+ pthread_mutex_lock(&(obj->data.execi.thread_info.mutex));
snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
+ pthread_mutex_unlock(&(obj->data.execi.thread_info.mutex));
+ }
+#endif /* HAVE_POPEN */
+ OBJ(imap_unseen) {
+ if (obj->global_mode && info.mail) { // this means we use info
+ if (info.mail->pos < 0) {
+ info.mail->last_update = current_update_time;
+ if (pthread_create(&(info.mail->thread_info.thread), NULL, (void*)imap_thread, (void*) info.mail)) {
+ ERR("Error starting thread");
+ }
+ info.mail->pos = register_thread(&(info.mail->thread_info));
+ }
+ // get a lock before reading
+ pthread_mutex_lock(&(info.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%lu", info.mail->unseen);
+ pthread_mutex_unlock(&(info.mail->thread_info.mutex));
+ } else if (obj->data.mail) { // this means we use obj
+ if (obj->data.mail->pos < 0) {
+ obj->data.mail->last_update = current_update_time;
+ if (pthread_create(&(obj->data.mail->thread_info.thread), NULL, (void*)imap_thread, (void*) obj->data.mail)) {
+ ERR("Error starting thread");
+ }
+ obj->data.mail->pos = register_thread(&(obj->data.mail->thread_info));
+ }
+ pthread_mutex_lock(&(obj->data.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%lu", obj->data.mail->unseen);
+ pthread_mutex_unlock(&(obj->data.mail->thread_info.mutex));
+ } else if (!obj->a) { // something is wrong, warn once then stop
+ ERR("Theres a problem with your imap_unseen settings. Check that the global IMAP settings are defined properly (line %li).", obj->line);
+ obj->a++;
+ }
+ }
+ OBJ(imap_messages) {
+ if (obj->global_mode && info.mail) { // this means we use info
+ if (info.mail->pos < 0) {
+ info.mail->last_update = current_update_time;
+ if (pthread_create(&(info.mail->thread_info.thread), NULL, (void*)imap_thread, (void*) info.mail)) {
+ ERR("Error starting thread");
+ }
+ info.mail->pos = register_thread(&(info.mail->thread_info));
+ }
+ pthread_mutex_lock(&(info.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%lu", info.mail->messages);
+ pthread_mutex_unlock(&(info.mail->thread_info.mutex));
+ } else if (obj->data.mail) { // this means we use obj
+ if (obj->data.mail->pos < 0) {
+ obj->data.mail->last_update = current_update_time;
+ if (pthread_create(&(obj->data.mail->thread_info.thread), NULL, (void*)imap_thread, (void*) obj->data.mail)) {
+ ERR("Error starting thread");
+ }
+ obj->data.mail->pos = register_thread(&(obj->data.mail->thread_info));
+ }
+ pthread_mutex_lock(&(obj->data.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%lu", obj->data.mail->messages);
+ pthread_mutex_unlock(&(obj->data.mail->thread_info.mutex));
+ } else if (!obj->a) { // something is wrong, warn once then stop
+ ERR("Theres a problem with your imap_messages settings. Check that the global IMAP settings are defined properly (line %li).", obj->line);
+ obj->a++;
+ }
+ }
+ OBJ(pop3_unseen) {
+ if (obj->global_mode && info.mail) { // this means we use info
+ if (info.mail->pos < 0) {
+ info.mail->last_update = current_update_time;
+ if (pthread_create(&(info.mail->thread_info.thread), NULL, (void*)pop3_thread, (void*) info.mail)) {
+ ERR("Error starting thread");
+ }
+ info.mail->pos = register_thread(&(info.mail->thread_info));
+ }
+ pthread_mutex_lock(&(info.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%lu", info.mail->unseen);
+ pthread_mutex_unlock(&(info.mail->thread_info.mutex));
+ } else if (obj->data.mail) { // this means we use obj
+ if (obj->data.mail->pos < 0) {
+ obj->data.mail->last_update = current_update_time;
+ if (pthread_create(&(obj->data.mail->thread_info.thread), NULL, (void*)pop3_thread, (void*) obj->data.mail)) {
+ ERR("Error starting thread");
+ }
+ obj->data.mail->pos = register_thread(&(obj->data.mail->thread_info));
+ }
+ pthread_mutex_lock(&(obj->data.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%lu", obj->data.mail->unseen);
+ pthread_mutex_unlock(&(obj->data.mail->thread_info.mutex));
+ } else if (!obj->a) { // something is wrong, warn once then stop
+ ERR("Theres a problem with your pop3_unseen settings. Check that the global POP3 settings are defined properly (line %li).", obj->line);
+ obj->a++;
+ }
+ }
+ OBJ(pop3_used) {
+ if (obj->global_mode && info.mail) { // this means we use info
+ if (info.mail->pos < 0) {
+ info.mail->last_update = current_update_time;
+ if (pthread_create(&(info.mail->thread_info.thread), NULL, (void*)pop3_thread, (void*) info.mail)) {
+ ERR("Error starting thread");
+ }
+ info.mail->pos = register_thread(&(info.mail->thread_info));
+ }
+ pthread_mutex_lock(&(info.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%.1f", info.mail->used/1024.0/1024.0);
+ pthread_mutex_unlock(&(info.mail->thread_info.mutex));
+ } else if (obj->data.mail) { // this means we use obj
+ if (obj->data.mail->pos < 0) {
+ obj->data.mail->last_update = current_update_time;
+ if (pthread_create(&(obj->data.mail->thread_info.thread), NULL, (void*)pop3_thread, (void*) obj->data.mail)) {
+ ERR("Error starting thread");
+ }
+ obj->data.mail->pos = register_thread(&(obj->data.mail->thread_info));
+ }
+ pthread_mutex_lock(&(obj->data.mail->thread_info.mutex));
+ snprintf(p, p_max_size, "%.1f", obj->data.mail->used/1024.0/1024.0);
+ pthread_mutex_unlock(&(obj->data.mail->thread_info.mutex));
+ } else if (!obj->a) { // something is wrong, warn once then stop
+ ERR("Theres a problem with your pop3_used settings. Check that the global POP3 settings are defined properly (line %li).", obj->line);
+ obj->a++;
+ }
}
- //parse_conky_vars(obj->data.execi.buffer, p, cur);
- }
-#endif
OBJ(fs_bar) {
if (obj->data.fs != NULL) {
if (obj->data.fs->size == 0)
v[obj->data.loadavg[0] -
1]);
}
+ OBJ(goto) {
+ new_goto(p, obj->data.i);
+ }
+ OBJ(tab) {
+ new_tab(p, obj->data.pair.a, obj->data.pair.b);
+ }
OBJ(hr) {
new_hr(p, obj->data.i);
}
+ OBJ(hddtemp) {
+ char *temp;
+ char unit;
+
+ temp = get_hddtemp_info(obj->data.hddtemp.dev,
+ obj->data.hddtemp.addr, obj->data.hddtemp.port, &unit);
+ if (!temp) {
+ snprintf(p, p_max_size, "N/A");
+ } else if (unit == '*') {
+ snprintf(p, p_max_size, "%s", temp);
+ } else {
+ snprintf(p, p_max_size, "%s°%c", temp, unit);
+ }
+ }
OBJ(offset) {
new_offset(p, obj->data.i);
}
if ((obj->data.ifblock.s)
&& (stat(obj->data.ifblock.s, &tmp) ==
-1)) {
- i = obj->data.ifblock.pos - 2;
+ i = obj->data.ifblock.pos;
if_jumped = 1;
- } else
+ } else {
if_jumped = 0;
+ }
}
OBJ(if_mounted) {
if ((obj->data.ifblock.s)
&& (!check_mount(obj->data.ifblock.s))) {
- i = obj->data.ifblock.pos - 2;
+ i = obj->data.ifblock.pos;
if_jumped = 1;
- } else
+ } else {
if_jumped = 0;
+ }
}
OBJ(if_running) {
if ((obj->data.ifblock.s)
&& system(obj->data.ifblock.s)) {
- i = obj->data.ifblock.pos - 2;
+ i = obj->data.ifblock.pos;
if_jumped = 1;
- } else
+ } else {
if_jumped = 0;
+ }
}
OBJ(kernel) {
snprintf(p, p_max_size, "%s", cur->uname_s.release);
/* memory stuff */
OBJ(mem) {
- human_readable(cur->mem * 1024, p, 6);
+ human_readable(cur->mem * 1024, p, 255);
}
OBJ(memmax) {
human_readable(cur->memmax * 1024, p, 255);
struct tm *tm = gmtime(&t);
strftime(p, p_max_size, obj->data.s, tm);
}
+ OBJ(tztime) {
+ char* oldTZ = NULL;
+ if (obj->data.tztime.tz) {
+ oldTZ = getenv("TZ");
+ setenv("TZ", obj->data.tztime.tz, 1);
+ tzset();
+ }
+ time_t t = time(NULL);
+ struct tm *tm = localtime(&t);
+ setlocale(LC_TIME, "");
+ strftime(p, p_max_size, obj->data.tztime.fmt, tm);
+ if (oldTZ) {
+ setenv("TZ", oldTZ, 1);
+ tzset();
+ } else {
+ unsetenv("TZ");
+ }
+ // Needless to free oldTZ since getenv gives ptr to static data
+ }
OBJ(totaldown) {
human_readable(obj->data.net->recv, p,
255);
OBJ(mpd_track) {
snprintf(p, p_max_size, "%s", cur->mpd.track);
}
+ OBJ(mpd_name) {
+ snprintf(p, p_max_size, "%s", cur->mpd.name);
+ }
+ OBJ(mpd_file) {
+ snprintf(p, p_max_size, "%s", cur->mpd.file);
+ }
OBJ(mpd_vol) {
snprintf(p, p_max_size, "%i", cur->mpd.volume);
}
(int) (cur->mpd.progress *
255.0f));
}
+ OBJ(mpd_smart) {
+ if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.title) < 2) {
+ snprintf(p, p_max_size, "%s", cur->mpd.file);
+ } else {
+ snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title);
+ }
+ }
#endif
-#ifdef BMPX
- OBJ(bmpx_title) {
- snprintf(p, p_max_size, "%s", cur->bmpx.title);
+#ifdef XMMS2
+ OBJ(xmms2_artist) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.artist);
}
- OBJ(bmpx_artist) {
- snprintf(p, p_max_size, "%s", cur->bmpx.artist);
+ OBJ(xmms2_album) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.album);
}
- OBJ(bmpx_album) {
- snprintf(p, p_max_size, "%s", cur->bmpx.album);
+ OBJ(xmms2_title) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.title);
}
- OBJ(bmpx_uri) {
- snprintf(p, p_max_size, "%s", cur->bmpx.uri);
+ OBJ(xmms2_genre) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.genre);
}
- OBJ(bmpx_track) {
- snprintf(p, p_max_size, "%i", cur->bmpx.track);
+ OBJ(xmms2_comment) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.comment);
}
- OBJ(bmpx_bitrate) {
- snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
+ OBJ(xmms2_decoder) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.decoder);
+ }
+ OBJ(xmms2_transport) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.transport);
+ }
+ OBJ(xmms2_url) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.url);
+ }
+ OBJ(xmms2_status) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.status);
+ }
+ OBJ(xmms2_date) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.date);
+ }
+ OBJ(xmms2_tracknr) {
+ if (cur->xmms2.tracknr != -1)
+ snprintf(p, p_max_size, "%i", cur->xmms2.tracknr);
+ }
+ OBJ(xmms2_bitrate) {
+ snprintf(p, p_max_size, "%i", cur->xmms2.bitrate);
+ }
+ OBJ(xmms2_id) {
+ snprintf(p, p_max_size, "%u", cur->xmms2.id);
+ }
+ OBJ(xmms2_size) {
+ snprintf(p, p_max_size, "%2.1f", cur->xmms2.size);
+ }
+ OBJ(xmms2_elapsed) {
+ int tmp = cur->xmms2.elapsed;
+ snprintf(p, p_max_size, "%02d:%02d",
+ tmp / 60000, (tmp / 1000) % 60);
+ }
+ OBJ(xmms2_duration) {
+ int tmp = cur->xmms2.duration;
+ snprintf(p, p_max_size, "%02d:%02d",
+ tmp / 60000, (tmp / 1000) % 60);
+ }
+ OBJ(xmms2_percent) {
+ snprintf(p, p_max_size, "%2.0f",
+ cur->xmms2.progress * 100);
+ }
+ OBJ(xmms2_bar) {
+ new_bar(p, obj->data.pair.a,
+ obj->data.pair.b,
+ (int) (cur->xmms2.progress *
+ 255.0f));
+ }
+ OBJ(xmms2_smart) {
+ if (strlen(cur->xmms2.title) < 2 && strlen(cur->xmms2.title) < 2) {
+ snprintf(p, p_max_size, "%s", cur->xmms2.url);
+ } else {
+ snprintf(p, p_max_size, "%s - %s", cur->xmms2.artist, cur->xmms2.title);
+ }
}
#endif
-#ifdef INFOPIPE
- OBJ(infopipe_protocol) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PROTOCOL]);
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ OBJ(xmms_status) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_STATUS]);
+ }
+ OBJ(xmms_title) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_TITLE]);
+ }
+ OBJ(xmms_length) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_LENGTH]);
+ }
+ OBJ(xmms_length_seconds) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_LENGTH_SECONDS]);
+ }
+ OBJ(xmms_position) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_POSITION]);
}
- OBJ(infopipe_version) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_VERSION]);
+ OBJ(xmms_position_seconds) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_POSITION_SECONDS]);
}
- OBJ(infopipe_status) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_STATUS]);
+ OBJ(xmms_bitrate) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_BITRATE]);
}
- OBJ(infopipe_playlist_tunes) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_TUNES]);
+ OBJ(xmms_frequency) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_FREQUENCY]);
}
- OBJ(infopipe_playlist_currtune) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_CURRTUNE]);
+ OBJ(xmms_channels) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_CHANNELS]);
}
- OBJ(infopipe_usec_position) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_USEC_POSITION]);
+ OBJ(xmms_filename) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_FILENAME]);
}
- OBJ(infopipe_position) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_POSITION]);
+ OBJ(xmms_playlist_length) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_PLAYLIST_LENGTH]);
}
- OBJ(infopipe_usec_time) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_USEC_TIME]);
+ OBJ(xmms_playlist_position) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_PLAYLIST_POSITION]);
}
- OBJ(infopipe_time) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_TIME]);
+ OBJ(xmms_bar) {
+ double progress;
+ progress= atof(cur->xmms.items[XMMS_POSITION_SECONDS]) /
+ atof(cur->xmms.items[XMMS_LENGTH_SECONDS]);
+ new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
}
- OBJ(infopipe_bitrate) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_BITRATE]);
+#endif
+#ifdef BMPX
+ OBJ(bmpx_title) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.title);
}
- OBJ(infopipe_frequency) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FREQUENCY]);
+ OBJ(bmpx_artist) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.artist);
}
- OBJ(infopipe_channels) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_CHANNELS]);
+ OBJ(bmpx_album) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.album);
}
- OBJ(infopipe_title) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_TITLE]);
+ OBJ(bmpx_uri) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.uri);
}
- OBJ(infopipe_file) {
- snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FILE]);
+ OBJ(bmpx_track) {
+ snprintf(p, p_max_size, "%i", cur->bmpx.track);
}
- OBJ(infopipe_bar) {
- double progress;
- progress= atof(cur->infopipe.items[INFOPIPE_USEC_POSITION]) /
- atof(cur->infopipe.items[INFOPIPE_USEC_TIME]);
- new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
+ OBJ(bmpx_bitrate) {
+ snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
}
#endif
OBJ(top) {
}
#endif
+#ifdef HAVE_ICONV
+ OBJ(iconv_start)
+ {
+ iconv_converting = 1;
+ iconv_selected = obj->a;
+
+ }
+ OBJ(iconv_stop)
+ {
+ iconv_converting = 0;
+ iconv_selected = 0;
+ }
+#endif
+
break;
}
{
unsigned int a = strlen(p);
+
+#ifdef HAVE_ICONV
+ if (a > 0 && iconv_converting && iconv_selected > 0 && (iconv_cd[iconv_selected - 1] != (iconv_t)(-1))) {
+ int bytes;
+ size_t dummy1, dummy2;
+ char *ptr = buff_in;
+ char *outptr = p;
+
+ dummy1 = dummy2 = a;
+
+ strncpy(buff_in, p, P_MAX_SIZE);
+
+ iconv(*iconv_cd[iconv_selected - 1], NULL, NULL, NULL, NULL);
+ while (dummy1 > 0) {
+ bytes = iconv(*iconv_cd[iconv_selected - 1], &ptr, &dummy1, &outptr, &dummy2);
+ if (bytes == -1) {
+ ERR("Iconv codeset conversion failed");
+ break;
+ }
+ }
+
+ /* It is nessecary when we are converting from multibyte to singlebyte codepage */
+ a = outptr - p;
+ }
+#endif
p += a;
p_max_size -= a;
}
struct information *cur = &info;
char *p;
+
special_count = 0;
/* update info */
}
}
+
last_update_time = current_update_time;
total_updates++;
//free(p);
}
}
-
-/*
- * text size
- */
-
-static int text_start_x, text_start_y; /* text start position in window */
-static int text_width, text_height;
-
#endif /* X11 */
static inline int get_string_width(const char *s)
#endif /* X11 */
}
-int fontchange = 0;
-
#ifdef X11
-static void text_size_updater(char *s)
-{
- int w = 0;
- char *p;
- int h = font_height();
- /* get string widths and skip specials */
- p = s;
- while (*p) {
- if (*p == SPECIAL_CHAR) {
- *p = '\0';
- w += get_string_width(s);
- *p = SPECIAL_CHAR;
-
- if (specials[special_index].type == BAR
- || specials[special_index].type == GRAPH) {
- w += specials[special_index].width;
- if (specials[special_index].height > h) {
- h = specials[special_index].height;
- h += font_ascent();
- }
- }
-
- else if (specials[special_index].type == OFFSET) {
- w += specials[special_index].arg + get_string_width("a"); /* filthy, but works */
- }
- else if (specials[special_index].type == VOFFSET) {
- h += specials[special_index].arg;
- }
- else if (specials[special_index].type == FONT) {
- fontchange = specials[special_index].font_added;
- selected_font = specials[special_index].font_added;
- h = font_height();
- }
-
-
- special_index++;
- s = p + 1;
- }
- p++;
- }
- w += get_string_width(s);
- if (w > text_width)
- text_width = w;
- if (text_width > maximum_width && maximum_width)
- text_width = maximum_width;
-
- text_height += h;
- if (fontchange) {
- selected_font = 0;
- }
-}
-#endif /* X11 */
-
+static void text_size_updater(char *s);
-#ifdef X11
+int last_font_height;
static void update_text_area()
{
int x, y;
text_width = minimum_width;
text_height = 0;
special_index = 0;
+ int first_font_height = last_font_height = font_height();
for_each_line(text_buffer, text_size_updater);
+ text_height -= first_font_height;
text_width += 1;
if (text_height < minimum_height)
text_height = minimum_height;
static int draw_mode; /* FG, BG or OUTLINE */
static long current_color;
+#ifdef X11
+static void text_size_updater(char *s)
+{
+ int w = 0;
+ char *p;
+ /* get string widths and skip specials */
+ p = s;
+ while (*p) {
+ if (*p == SPECIAL_CHAR) {
+ *p = '\0';
+ w += get_string_width(s);
+ *p = SPECIAL_CHAR;
+
+ if (specials[special_index].type == BAR
+ || specials[special_index].type == GRAPH) {
+ w += specials[special_index].width;
+ if (specials[special_index].height > last_font_height) {
+ last_font_height = specials[special_index].height;
+ last_font_height += font_ascent();
+ }
+ } else if (specials[special_index].type == OFFSET) {
+ w += specials[special_index].arg + get_string_width("a"); /* filthy, but works */
+ } else if (specials[special_index].type == VOFFSET) {
+ last_font_height += specials[special_index].arg;
+ } else if (specials[special_index].type == GOTO) {
+ if (specials[special_index].arg >= 0)
+ w += (int)specials[special_index].arg - cur_x;
+ } else if (specials[special_index].type == TAB) {
+ int start = specials[special_index].arg;
+ int step = specials[special_index].width;
+ if (!step || step < 0)
+ step = 10;
+ w += step - (cur_x - text_start_x - start) % step;
+ } else if (specials[special_index].type == FONT) {
+ selected_font = specials[special_index].font_added;
+ if (font_height() > last_font_height) {
+ last_font_height = font_height();
+ }
+ }
+
+ special_index++;
+ s = p + 1;
+ }
+ p++;
+ }
+ w += get_string_width(s);
+ if (w > text_width) {
+ text_width = w;
+ }
+ if (text_width > maximum_width && maximum_width) {
+ text_width = maximum_width;
+ }
+
+ text_height += last_font_height;
+ last_font_height = font_height();
+}
+#endif /* X11 */
+
static inline void set_foreground_color(long c)
{
current_color = c;
specials[special_index].height;
int bar_usage =
specials[special_index].arg;
- int by;
-
-#ifdef XFT
- if (use_xft) {
- by = cur_y - (font_ascent() + h) / 2 - 1;
- } else
-#endif
- {
- by = cur_y - (font_ascent()/2) - 1;
- }
- if (h < (font_height())) {
+ int by = cur_y - (font_ascent() / 2) - 1;
+ if (h < font_height()) {
by -= h / 2 - 1;
}
w = specials[special_index].width;
}
int h =
specials[special_index].height;
- int by;
-#ifdef XFT
- if (use_xft) {
- by = cur_y - (font_ascent() + h) / 2 - 1;
- } else
-#endif
- {
- by = cur_y - (font_ascent()/2) - 1;
- }
- if (h < (font_height())) {
+ unsigned long last_colour = current_color;
+ int by = cur_y - (font_ascent()/2) - 1;
+ if (h < font_height()) {
by -= h / 2 - 1;
}
w = specials[special_index].width;
float gradient_factor = 0;
float gradient_update = 0;
unsigned long tmpcolour = current_color;
- if (specials[special_index].first_colour != specials[special_index].last_colour) {
- tmpcolour = specials[special_index].first_colour;
- gradient_size = gradient_max(specials[special_index].first_colour, specials[special_index].last_colour);
- gradient_factor = (float)gradient_size / (w - 3);
+ if (specials[special_index].last_colour != 0 || specials[special_index].first_colour != 0) {
+ tmpcolour = specials[special_index].last_colour;
+ gradient_size = gradient_max(specials[special_index].last_colour, specials[special_index].first_colour);
+ gradient_factor = (float)gradient_size / (w - 2);
}
- for (i = 0; i < w - 3; i++) {
- if (specials[special_index].first_colour != specials[special_index].last_colour) {
+ for (i = w - 2; i > -1; i--) {
+ if (specials[special_index].last_colour != 0 || specials[special_index].first_colour != 0) {
XSetForeground(display, window.gc, tmpcolour);
gradient_update += gradient_factor;
while (gradient_update > 0) {
- tmpcolour = do_gradient(tmpcolour, specials[special_index].last_colour);
+ tmpcolour = do_gradient(tmpcolour, specials[special_index].first_colour);
gradient_update--;
}
}
- if (i / ((float) (w - 3) / (specials[special_index].graph_width)) > j) {
+ if ((w - i) / ((float) (w - 2) / (specials[special_index].graph_width)) > j && j < MAX_GRAPH_DEPTH - 3) {
j++;
- }
- XDrawLine(display, window.drawable, window.gc, cur_x + i + 2, by + h, cur_x + i + 2, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale); /* this is mugfugly, but it works */
+ }
+ XDrawLine(display, window.drawable, window.gc, cur_x + i + 1, by + h, cur_x + i + 1, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale); /* this is mugfugly, but it works */
}
if (specials[special_index].
height > cur_y_add
specials
[special_index].height;
}
- }
- if (draw_mode == BG) {
+/* if (draw_mode == BG) {
set_foreground_color(default_bg_color);
}
else if (draw_mode == OUTLINE) {
set_foreground_color(default_out_color);
} else {
set_foreground_color(default_fg_color);
- }
+ }*/
+ set_foreground_color(last_colour);
+ }
break;
case FONT:
- if (fontchange) {
+ {
+ int old = font_ascent();
cur_y -= font_ascent();
selected_font = specials[special_index].font_added;
- cur_y += font_ascent();
-#ifdef XFT
- if (!use_xft || use_xdbe)
-#endif
- {
- set_font();
+ if (cur_y + font_ascent() < cur_y + old) {
+ cur_y += old;
+ } else {
+ cur_y += font_ascent();
}
+ set_font();
}
break;
case FG:
arg);
break;
- case OFFSET:
- {
- w += specials[special_index].arg;
- }
+ case OFFSET:
+ w += specials[special_index].arg;
+ break;
+
+ case VOFFSET:
+ cur_y += specials[special_index].arg;
+ break;
+
+ case GOTO:
+ if (specials[special_index].arg >= 0)
+ cur_x = (int)specials[special_index].arg;
break;
- case VOFFSET:
+
+ case TAB:
{
- cur_y += specials[special_index].arg;
+ int start = specials[special_index].arg;
+ int step = specials[special_index].width;
+ if (!step || step < 0)
+ step = 10;
+ w = step - (cur_x - text_start_x - start) % step;
}
break;
draw_string(s);
cur_y += font_descent();
- if (fontchange) {
- selected_font = 0;
- }
#endif /* X11 */
}
static void draw_stuff()
{
#ifdef X11
+ selected_font = 0;
if (draw_shades && !draw_outline) {
text_start_x++;
text_start_y++;
}
if (draw_outline) {
+ selected_font = 0;
int i, j;
for (i = -1; i < 2; i++)
for (j = -1; j < 2; j++) {
#ifdef X11
Region region = XCreateRegion();
+ int event_base, error_base;
+#ifdef HAVE_XDAMAGE
+ if (!XDamageQueryExtension (display, &event_base, &error_base)) {
+ ERR("Xdamage extension unavailable");
+ }
+ Damage damage = XDamageCreate(display, window.window, XDamageReportNonEmpty);
+ XserverRegion region2 = XFixesCreateRegionFromWindow(display, window.window, 0);
+ XserverRegion part = XFixesCreateRegionFromWindow(display, window.window, 0);
+#endif /* HAVE_XDAMAGE */
#endif /* X11 */
info.looped = 0;
update_text();
#ifdef X11
}
-#ifdef OWN_WINDOW
- if (own_window) {
- set_transparent_background(window.window);
- }
-#endif
}
if (need_to_update) {
#endif
need_to_update = 0;
-
+ selected_font = 0;
update_text_area();
#ifdef OWN_WINDOW
if (own_window) {
/* resize window if it isn't right size */
if (!fixed_size &&
- (text_width + border_margin * 2 !=
+ (text_width + border_margin * 2 + 1 !=
window.width
- || text_height + border_margin * 2 !=
+ || text_height + border_margin * 2 + 1 !=
window.height)) {
window.width =
text_width +
text_height +
border_margin * 2 + 1;
XResizeWindow(display,
- window.window,
+ window.drawable,
window.width,
window.height);
+ if (own_window) {
+ set_transparent_background(window.drawable);
+ }
}
/* move window if it isn't in right position */
set_font();
}
break;
+
+ case ButtonPress:
+ if (own_window)
+ {
+ /* forward the click to the desktop window */
+ XUngrabPointer(display, ev.xbutton.time);
+ ev.xbutton.window = window.desktop;
+ XSendEvent(display, ev.xbutton.window, False, ButtonPressMask, &ev);
+ }
+ break;
+
+ case ButtonRelease:
+ if (own_window)
+ {
+ /* forward the release to the desktop window */
+ ev.xbutton.window = window.desktop;
+ XSendEvent(display, ev.xbutton.window, False, ButtonReleaseMask, &ev);
+ }
+ break;
+
#endif
default:
+#ifdef HAVE_XDAMAGE
+ if (ev.type == event_base + XDamageNotify) {
+ XDamageNotifyEvent *dev = (XDamageNotifyEvent *) &ev;
+ XFixesSetRegion(display, part, &dev->area, 1);
+ XFixesUnionRegion(display, region2, region2, part);
+ XDamageSubtract(display, damage, region2, None);
+ XFixesSetRegion(display, region2, 0, 0);
+ }
+#endif /* HAVE_XDAMAGE */
break;
}
}
g_signal_pending=0;
}
-#ifdef X11
+#if defined(X11) && defined(HAVE_XDAMAGE)
+ XDamageDestroy(display, damage);
+ XFixesDestroyRegion(display, region2);
+ XFixesDestroyRegion(display, part);
XDestroyRegion(region);
region = NULL;
-#endif /* X11 */
+#endif /* X11 && HAVE_XDAMAGE */
}
static void load_config_file(const char *);
/* reload the config file */
void reload_config(void)
{
+ //lock_all_threads();
+ threads_runnable++;
+ if (info.cpu_usage) {
+ free(info.cpu_usage);
+ info.cpu_usage = NULL;
+ }
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ if (info.xmms.thread) {
+ if (destroy_xmms_thread()!=0)
+ {
+ ERR("error destroying xmms_player thread");
+ }
+ }
+#endif
+#ifdef TCP_PORT_MONITOR
+ destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
+#endif
+
if (current_config) {
clear_fs_stats();
load_config_file(current_config);
#endif /* X11 */
#ifdef TCP_PORT_MONITOR
- destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
info.p_tcp_port_monitor_collection = NULL;
#endif
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ if ( (!info.xmms.thread) && (info.xmms.current_project > PROJECT_NONE) &&
+ (create_xmms_thread() !=0) )
+ {
+ CRIT_ERR("unable to create xmms_player thread!");
+ }
+#endif
extract_variable_text(text);
free(text);
text = NULL;
update_text();
}
+ thread_count = 0;
}
void clean_up(void)
{
+ //lock_all_threads();
+ threads_runnable++;
+ if (info.cpu_usage) {
+ free(info.cpu_usage);
+ info.cpu_usage = NULL;
+ }
#ifdef X11
#ifdef XDBE
if (use_xdbe) {
}
#endif
#ifdef OWN_WINDOW
- if (own_window)
+ if (own_window)
+ {
XDestroyWindow(display, window.window);
+ XClearWindow(display, RootWindow(display, screen));
+ XFlush(display);
+ }
else
#endif
{
destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
info.p_tcp_port_monitor_collection = NULL;
#endif
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ if ( info.xmms.thread && (destroy_xmms_thread()!=0) )
+ {
+ ERR("error destroying xmms_player thread");
+ }
+#endif
}
static int string_to_bool(const char *s)
#ifdef MPD
strcpy(info.mpd.host, "localhost");
info.mpd.port = 6600;
- info.mpd.status = "Checking status...";
+ info.mpd.status = NULL;
+ info.mpd.artist = NULL;
+ info.mpd.album = NULL;
+ info.mpd.title = NULL;
+ info.mpd.random = NULL;
+ info.mpd.track = NULL;
+ info.mpd.name = NULL;
+ info.mpd.file = NULL;
+#endif
+#ifdef XMMS2
+ info.xmms2.artist = NULL;
+ info.xmms2.album = NULL;
+ info.xmms2.title = NULL;
+ info.xmms2.genre = NULL;
+ info.xmms2.comment = NULL;
+ info.xmms2.decoder = NULL;
+ info.xmms2.transport = NULL;
+ info.xmms2.url = NULL;
+ info.xmms2.status = NULL;
#endif
use_spacer = 0;
#ifdef X11
maximum_width = 0;
#ifdef OWN_WINDOW
own_window = 0;
- strcpy(wm_class_name, "conky");
+ window.type=TYPE_NORMAL;
+ window.hints=0;
+ strcpy(window.wm_class_name, "conky");
#endif
stippled_borders = 0;
border_margin = 3;
tcp_port_monitor_collection_args.min_port_monitors = MIN_PORT_MONITORS_DEFAULT;
tcp_port_monitor_args.min_port_monitor_connections = MIN_PORT_MONITOR_CONNECTIONS_DEFAULT;
#endif
+
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ info.xmms.current_project=PROJECT_NONE;
+#endif
}
static void load_config_file(const char *f)
}
CONF("on_bottom") {
if(value)
+ ERR("on_bottom is deprecated. use own_window_hints below");
on_bottom = string_to_bool(value);
+ if (on_bottom)
+ SET_HINT(window.hints,HINT_BELOW);
+
else
CONF_ERR;
}
CONF_ERR;
}
#endif /* X11 */
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ CONF("xmms_player") {
+ if (value) {
+ if (strncmp(value,"none",4)==0)
+ info.xmms.current_project=PROJECT_NONE;
+ else if (strncmp(value,"xmms",4)==0)
+ info.xmms.current_project=PROJECT_XMMS;
+ else if (strncmp(value,"bmp",3)==0)
+ info.xmms.current_project=PROJECT_BMP;
+ else if (strncmp(value,"audacious",9)==0)
+ info.xmms.current_project=PROJECT_AUDACIOUS;
+ else if (strncmp(value,"infopipe",8)==0)
+ info.xmms.current_project=PROJECT_INFOPIPE;
+ else
+ CONF_ERR;
+ }
+ else
+ CONF_ERR;
+ }
+#endif
+ CONF("imap") {
+ if (value) {
+ info.mail = parse_mail_args(IMAP, value);
+ } else {
+ CONF_ERR;
+ }
+ }
+ CONF("pop3") {
+ if (value) {
+ info.mail = parse_mail_args(POP3, value);
+ } else {
+ CONF_ERR;
+ }
+ }
#ifdef MPD
CONF("mpd_host") {
if (value)
- strcpy(info.mpd.host, value);
+ strncpy(info.mpd.host, value, 127);
else
CONF_ERR;
}
CONF_ERR;
}
}
+ CONF("mpd_password") {
+ if (value)
+ strncpy(info.mpd.password, value, 127);
+ else
+ CONF_ERR;
+ }
#endif
CONF("cpu_avg_samples") {
if (value) {
CONF_ERR;
}
CONF("xftfont") {
+ if (use_xft) {
#else
CONF("use_xft") {
if (string_to_bool(value))
}
CONF("font") {
#endif
- if (use_xft) {
if (value) {
set_first_font(value);
} else
CONF_ERR;
+#ifdef XFT
}
+#endif
}
CONF("gap_x") {
if (value)
own_window = string_to_bool(value);
}
CONF("wm_class_name") {
- strncpy(wm_class_name, value, sizeof(wm_class_name)-1);
- wm_class_name[sizeof(wm_class_name)-1] = 0;
+ memset(window.wm_class_name,0,sizeof(window.wm_class_name));
+ strncpy(window.wm_class_name, value, sizeof(window.wm_class_name)-1);
}
CONF("own_window_transparent") {
set_transparent = string_to_bool(value);
}
CONF("own_window_colour") {
- background_colour = get_x11_color(value);
+ if (value) {
+ background_colour = get_x11_color(value);
+ } else {
+ ERR("Invalid colour for own_winder_colour (try omitting the '#' for hex colours");
+ }
+ }
+ CONF("own_window_hints") {
+ if (value) {
+ char *p_hint, *p_save;
+ char delim[] = ", ";
+
+ /* tokenize the value into individual hints */
+ if ((p_hint=strtok_r(value, delim, &p_save)) != NULL)
+ do {
+ /*fprintf(stderr, "hint [%s] parsed\n", p_hint);*/
+ if (strncmp(p_hint,"undecorate",10) == 0)
+ SET_HINT(window.hints,HINT_UNDECORATED);
+ else if (strncmp(p_hint,"below",5) == 0)
+ SET_HINT(window.hints,HINT_BELOW);
+ else if (strncmp(p_hint,"above",5) == 0)
+ SET_HINT(window.hints,HINT_ABOVE);
+ else if (strncmp(p_hint,"sticky",6) == 0)
+ SET_HINT(window.hints,HINT_STICKY);
+ else if (strncmp(p_hint,"skip_taskbar",12) == 0)
+ SET_HINT(window.hints,HINT_SKIP_TASKBAR);
+ else if (strncmp(p_hint,"skip_pager",10) == 0)
+ SET_HINT(window.hints,HINT_SKIP_PAGER);
+ else
+ CONF_ERR;
+
+ p_hint=strtok_r(NULL, delim, &p_save);
+ }
+ while (p_hint!=NULL);
+ }
+ }
+ CONF("own_window_type") {
+ if (value) {
+ if (strncmp(value,"normal",6)==0)
+ window.type = TYPE_NORMAL;
+ else if (strncmp(value,"desktop",7)==0)
+ window.type = TYPE_DESKTOP;
+ else if (strncmp(value,"override",8)==0)
+ window.type = TYPE_OVERRIDE;
+ else
+ CONF_ERR;
+ }
}
#endif
CONF("stippled_borders") {
break;
}
fclose(fp);
+ text_lines = line + 1;
return;
}
#ifdef TCP_PORT_MONITOR
fclose(fp);
#undef CONF_ERR
+
+
}
/* : means that character before that takes an argument */
tcp_port_monitor_collection_args.min_port_monitors = MIN_PORT_MONITORS_DEFAULT;
tcp_port_monitor_args.min_port_monitor_connections = MIN_PORT_MONITOR_CONNECTIONS_DEFAULT;
#endif
+
+#if defined(XMMS)
+ SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_XMMS);
+#endif
+#if defined(BMP)
+ SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_BMP);
+#endif
+#if defined(AUDACIOUS)
+ SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_AUDACIOUS);
+#endif
+#if defined(INFOPIPE)
+ SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_INFOPIPE);
+#endif
/* handle command line parameters that don't change configs */
#ifdef X11
switch (c) {
case 'v':
case 'V':
- printf
- ("Conky " VERSION " compiled " __DATE__ "\n");
- return 0;
-
+ print_version();
case 'c':
/* if current_config is set to a strdup of CONFIG_FILE, free it (even
* though free() does the NULL check itself;), then load optarg value */
#else
optind = 0;
#endif
+
+#if defined(__FreeBSD__)
+ if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null",
+ O_RDONLY, "kvm_open")) == NULL)
+ CRIT_ERR( "cannot read kvm");
+#endif
while (1) {
int c = getopt(argc,
free(text);
}
text = NULL;
+ /* fork */
+ if (fork_to_background) {
+ int pid = fork();
+ switch (pid) {
+ case -1:
+ ERR("can't fork() to background: %s",
+ strerror(errno));
+ break;
+
+ case 0:
+ /* child process */
+ sleep(1);
+ fprintf(stderr,"\n");fflush(stderr);
+ break;
+
+ default:
+ /* parent process */
+ fprintf(stderr,"Conky: forked to background, pid is %d\n",pid);
+ fflush(stderr);
+ return 0;
+ }
+ }
update_uname();
generate_text();
#ifdef X11
+ selected_font = 0;
update_text_area(); /* to get initial size of the window */
-#if defined OWN_WINDOW
- init_window
- (own_window,
- wm_class_name,
- text_width + border_margin * 2 + 1,
- text_height + border_margin * 2 + 1,
- on_bottom, fixed_pos, set_transparent, background_colour, info.uname_s.nodename);
-#else
init_window
(own_window,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
- on_bottom, set_transparent, background_colour, info.uname_s.nodename);
+ set_transparent, background_colour, info.uname_s.nodename, argv, argc);
-#endif
-
+ selected_font = 0;
update_text_area(); /* to position text/window on screen */
#endif /* X11 */
draw_stuff();
#endif /* X11 */
- /* fork */
- if (fork_to_background) {
- int ret = fork();
- switch (ret) {
- case -1:
- ERR("can't fork() to background: %s",
- strerror(errno));
- break;
-
- case 0:
- break;
-
- default:
- fprintf
- (stderr,
- "Conky: forked to background, pid is %d\n",
- ret);
- return 0;
- }
- }
/* Set signal handlers */
act.sa_handler = signal_handler;
ERR("error setting signal handler: %s", strerror(errno) );
}
-#ifdef INFOPIPE
- /* joinable thread for infopipe activity */
- pthread_attr_init(&info.infopipe.thread_attr);
- pthread_attr_setdetachstate(&info.infopipe.thread_attr, PTHREAD_CREATE_JOINABLE);
- /* init mutexex */
- pthread_mutex_init(&info.infopipe.item_mutex, NULL);
- pthread_mutex_init(&info.infopipe.runnable_mutex, NULL);
- /* init runnable condition for worker thread */
- pthread_mutex_lock(&info.infopipe.runnable_mutex);
- info.infopipe.runnable=1;
- pthread_mutex_unlock(&info.infopipe.runnable_mutex);
- if (pthread_create(&info.infopipe.thread, &info.infopipe.thread_attr, infopipe_thread_func, NULL))
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ if ( (info.xmms.current_project > PROJECT_NONE) && (create_xmms_thread() !=0) )
{
- CRIT_ERR("unable to create infopipe thread!");
+ CRIT_ERR("unable to create xmms_player thread!");
}
#endif
main_loop();
-
-#ifdef INFOPIPE
- /* signal infopipe worker thread to terminate */
- pthread_mutex_lock(&info.infopipe.runnable_mutex);
- info.infopipe.runnable=0;
- pthread_mutex_unlock(&info.infopipe.runnable_mutex);
- /* destroy thread attribute and wait for thread */
- pthread_attr_destroy(&info.infopipe.thread_attr);
- if (pthread_join(info.infopipe.thread, NULL))
- {
- ERR("error joining infopipe thread");
+
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ if ( info.xmms.thread && (destroy_xmms_thread()!=0) )
+ {
+ ERR("error destroying xmms_player thread");
}
- /* destroy mutexes */
- pthread_mutex_destroy(&info.infopipe.item_mutex);
- pthread_mutex_destroy(&info.infopipe.runnable_mutex);
-#endif
+#endif
+#if defined(__FreeBSD__)
+ kvm_close(kd);
+#endif
+
return 0;
}