/* border */
static int draw_borders;
+static int draw_graph_borders;
static int stippled_borders;
static int draw_shades, draw_outline;
" / $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"
OBJ_mpd_track,
OBJ_mpd_percent,
#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_artist,
+ OBJ_bmpx_album,
+ OBJ_bmpx_track,
+ OBJ_bmpx_uri,
+ OBJ_bmpx_bitrate,
+#endif
#ifdef TCP_PORT_MONITOR
OBJ_tcp_portmon,
#endif
free(objs[i].data.tail.logfile);
free(objs[i].data.tail.buffer);
break;
- case OBJ_text:
- case OBJ_font:
+ case OBJ_text: case OBJ_font:
free(objs[i].data.s);
break;
case OBJ_exec:
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);
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(execi, 0) unsigned int n;
if (!arg
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
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)
+ memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
+ END
+ OBJ(bmpx_artist, INFO_BMPX)
+ memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
+ END
+ OBJ(bmpx_album, INFO_BMPX)
+ memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
+ END
+ OBJ(bmpx_track, INFO_BMPX)
+ memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
+ END
+ OBJ(bmpx_uri, INFO_BMPX)
+ memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
+ END
+ OBJ(bmpx_bitrate, INFO_BMPX)
+ memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
+ END
+#endif
#ifdef TCP_PORT_MONITOR
OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR)
int argc, port_begin, port_end, item, connection_index;
obj, sizeof(struct text_object));
free(obj);
}
-
-
}
continue;
} else {
free(obj);
}
}
-
}
-
p++;
}
-
obj = create_plain_text(s);
if(obj != NULL) {
// allocate memory for the object
- retval->text_objects = realloc(retval->text_objects,
+ 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++],
list = extract_variable_text_internal(p);
text_objects = list->text_objects;
- text_object_count = list->text_object_count;
+ text_object_count = list->text_object_count;
free(list);
return;
}
-void parse_conky_vars(char * text, char * p, struct information *cur){
+void parse_conky_vars(char * text, char * p, struct information *cur) {
struct text_object_list *object_list = extract_variable_text_internal(text);
generate_text_internal(p, P_MAX_SIZE, object_list->text_objects, object_list->text_object_count, cur);
free(object_list);
}
OBJ(exec) {
- char *output = p;
FILE *fp = popen(obj->data.s, "r");
int length = fread(p, 1, p_max_size, fp);
(void) pclose(fp);
-
- output[length] = '\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);
+ //parse_conky_vars(output, p, cur);
}
OBJ(execbar) {
char *p2 = p;
}
OBJ(execibar) {
- if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+ 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;
}
}
OBJ(execigraph) {
- if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+ 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;
}
OBJ(execi) {
- char *output = obj->data.execi.buffer;
- if (current_update_time - obj->data.execi.last_update >= obj->data.execi.interval) {
+ 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);
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);
+ //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) {
+ 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;
+ }
if (!running) {
running = 1;
pthread_create( &execthread, NULL, (void*)threaded_exec, (void*) obj);
pthread_mutex_lock( &mutex1 );
obj->data.execi.last_update = current_update_time;
pthread_mutex_unlock( &mutex1 );
- } else {
- pthread_join( execthread, NULL);
- running = 0;
}
+ snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
}
- parse_conky_vars(obj->data.execi.buffer, p, cur);
+ //parse_conky_vars(obj->data.execi.buffer, p, cur);
}
#endif
OBJ(fs_bar) {
255.0f));
}
#endif
+#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(xmms_position_seconds) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_POSITION_SECONDS]);
+ }
+ OBJ(xmms_bitrate) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_BITRATE]);
+ }
+ OBJ(xmms_frequency) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_FREQUENCY]);
+ }
+ OBJ(xmms_channels) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_CHANNELS]);
+ }
+ OBJ(xmms_filename) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_FILENAME]);
+ }
+ OBJ(xmms_playlist_length) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_PLAYLIST_LENGTH]);
+ }
+ OBJ(xmms_playlist_position) {
+ snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_PLAYLIST_POSITION]);
+ }
+ 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));
+ }
+#endif
+#ifdef BMPX
+ OBJ(bmpx_title) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.title);
+ }
+ OBJ(bmpx_artist) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.artist);
+ }
+ OBJ(bmpx_album) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.album);
+ }
+ OBJ(bmpx_uri) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.uri);
+ }
+ OBJ(bmpx_track) {
+ snprintf(p, p_max_size, "%i", cur->bmpx.track);
+ }
+ OBJ(bmpx_bitrate) {
+ snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
+ }
+#endif
OBJ(top) {
if (obj->data.top.type == TOP_NAME
&& obj->data.top.num >= 0
OBJ(tail) {
- if (current_update_time -obj->data.tail.last_update >= obj->data.tail.interval) {
+ if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
+ snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
+ } else {
obj->data.tail.last_update = current_update_time;
FILE *fp;
int i;
if (obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] == '\n') {
obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] = '\0';
}
+ snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
freetail(freetmp);
} else {
strcpy(obj->data.tail.buffer, "Logfile Empty");
+ snprintf(p, p_max_size, "Logfile Empty");
} /* if readlines */
} /* fp == NULL */
} /* if cur_upd_time >= */
- parse_conky_vars(obj->data.tail.buffer, p, cur);
+ //parse_conky_vars(obj->data.tail.buffer, p, cur);
}
OBJ(head) {
- if (current_update_time -obj->data.tail.last_update >= obj->data.tail.interval) {
+ if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
+ snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
+ } else {
obj->data.tail.last_update = current_update_time;
FILE *fp;
tailstring *head = NULL;
if (obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] == '\n') {
obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] = '\0';
}
+ snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
} else {
strcpy(obj->data.tail.buffer, "Logfile Empty");
+ snprintf(p, p_max_size, "Logfile Empty");
} /* if readlines > 0 */
} /* if fp == null */
} /* cur_upd_time >= */
- parse_conky_vars(obj->data.tail.buffer, p, cur);
+ //parse_conky_vars(obj->data.tail.buffer, p, cur);
}
#ifdef TCP_PORT_MONITOR
update_stuff(cur);
+ /* add things to the buffer */
+
/* generate text */
p = text_buffer;
width_of_s = get_string_width(s);
if (out_to_console) {
printf("%s\n", s);
+ fflush(stdout); /* output immediately, don't buffer */
}
/* daemon_run(s); the daemon can be called here, but we need to have a buffer in daemon_run() and we need to tell it when everything is ready to be sent */
memset(tmpstring1,0,TEXT_BUFFER_SIZE);
w = text_start_x + text_width - cur_x - 1;
if (w < 0)
w = 0;
- XSetLineAttributes(display,
- window.gc, 1,
- LineSolid,
- CapButt,
- JoinMiter);
- XDrawRectangle(display,
- window.drawable,
- window.gc, cur_x,
- by, w, h);
+ if (draw_graph_borders) {
+ XSetLineAttributes(display, window.gc, 1, LineSolid, CapButt, JoinMiter);
+ XDrawRectangle(display,window.drawable, window.gc, cur_x, by, w, h);
+ }
XSetLineAttributes(display,
window.gc, 1,
LineSolid,
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) {
+ if (destroy_xmms_thread()!=0)
+ {
+ ERR("error destroying xmms_player thread");
+ }
+ }
+ 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;
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)
default_fg_color = WhitePixel(display, screen);
default_bg_color = BlackPixel(display, screen);
default_out_color = BlackPixel(display, screen);
- draw_borders = 0;
draw_shades = 1;
+ draw_borders = 0;
+ draw_graph_borders = 1;
draw_outline = 0;
set_first_font("6x10");
gap_x = 5;
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_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
#ifdef MPD
CONF("mpd_host") {
if (value)
CONF("draw_borders") {
draw_borders = string_to_bool(value);
}
+ CONF("draw_graph_borders") {
+ draw_graph_borders = string_to_bool(value);
+ }
CONF("draw_shades") {
draw_shades = string_to_bool(value);
}
use_xft = string_to_bool(value);
}
CONF("font") {
- if (!use_xft) {
- if (value) {
- set_first_font(value);
- } else
- CONF_ERR;
- }
+ if (value) {
+ set_first_font(value);
+ } else
+ CONF_ERR;
}
CONF("xftalpha") {
if (value && font_count >= 0)
CONF_ERR;
}
CONF("xftfont") {
+ if (use_xft) {
#else
CONF("use_xft") {
if (string_to_bool(value))
}
CONF("font") {
#endif
- if (value) {
- set_first_font(value);
- } else
- CONF_ERR;
+ if (value) {
+ set_first_font(value);
+ } else
+ CONF_ERR;
+#ifdef XFT
+ }
+#endif
}
CONF("gap_x") {
if (value)
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
ERR("error setting signal handler: %s", strerror(errno) );
}
+#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 xmms_player thread!");
+ }
+#endif
+
main_loop();
+#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
+ if ( info.xmms.thread && (destroy_xmms_thread()!=0) )
+ {
+ ERR("error destroying xmms_player thread");
+ }
+#endif
+
return 0;
}