diff --git a/configure.ac.in b/configure.ac.in index 8024698b..e00a60be 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -4,7 +4,7 @@ dnl major, minor and micro version macros. m4_define([conky_version_major], [1]) m4_define([conky_version_minor], [4]) m4_define([conky_version_micro], [7]) -m4_define([conky_version_tag], [svn]) dnl [] for releases +m4_define([conky_version_tag], []) dnl [] for releases m4_define([conky_version_revision],[r@REVISION@]) m4_define([conky_version], [conky_version_major().conky_version_minor().conky_version_micro()ifelse( diff --git a/src/common.c b/src/common.c index bed99013..c2c95224 100644 --- a/src/common.c +++ b/src/common.c @@ -233,7 +233,12 @@ void update_stuff() #ifdef MPD if (NEED(INFO_MPD)) { if (!mpd_timed_thread) { + clear_mpd_stats(&info); mpd_timed_thread = timed_thread_create((void*)update_mpd, (void*) NULL, update_interval * 1000000); + if (!mpd_timed_thread) { + ERR("Failed to create MPD thread"); + } + timed_thread_register(mpd_timed_thread, &mpd_timed_thread); } } #endif diff --git a/src/conky.c b/src/conky.c index a79720df..959e7fd0 100644 --- a/src/conky.c +++ b/src/conky.c @@ -3140,13 +3140,15 @@ static struct text_object *construct_text_object(const char *s, const char *arg, OBJ(mpd_artist, INFO_MPD) END OBJ(mpd_title, INFO_MPD) { - if (arg) - { - sscanf (arg, "%d", &info.mpd.max_title_len); - if (info.mpd.max_title_len > 0) - info.mpd.max_title_len++; - else - CRIT_ERR ("mpd_title: invalid length argument"); + if (arg) { + sscanf (arg, "%d", &info.mpd.max_title_len); + if (info.mpd.max_title_len > 0) { + info.mpd.max_title_len++; + } else { + CRIT_ERR ("mpd_title: invalid length argument"); + } + } else { + info.mpd.max_title_len = 0; } } END OBJ(mpd_random, INFO_MPD) @@ -3192,13 +3194,15 @@ static struct text_object *construct_text_object(const char *s, const char *arg, OBJ(audacious_status, INFO_AUDACIOUS) END OBJ(audacious_title, INFO_AUDACIOUS) { - if (arg) - { - sscanf (arg, "%d", &info.audacious.max_title_len); - if (info.audacious.max_title_len > 0) + if (arg) { + sscanf (arg, "%d", &info.audacious.max_title_len); + if (info.audacious.max_title_len > 0) { + info.audacious.max_title_len++; + } else { + CRIT_ERR ("audacious_title: invalid length argument"); + } + } else { info.audacious.max_title_len++; - else - CRIT_ERR ("audacious_title: invalid length argument"); } } END @@ -4967,7 +4971,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object * 255.0f)); } OBJ(mpd_smart) { - if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.title) < 2) { + if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.artist) < 2) { snprintf(p, p_max_size, "%s", cur->mpd.file); } else { snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title); @@ -7428,7 +7432,7 @@ int main(int argc, char **argv) struct sigaction act, oact; g_signal_pending=0; - memset(&info, 0, sizeof(info) ); + memset(&info, 0, sizeof(info)); #ifdef TCP_PORT_MONITOR tcp_port_monitor_args.max_port_monitor_connections = MAX_PORT_MONITOR_CONNECTIONS_DEFAULT; diff --git a/src/conky.h b/src/conky.h index 0d893b76..ce8722c0 100644 --- a/src/conky.h +++ b/src/conky.h @@ -619,6 +619,7 @@ char *get_apm_battery_time(void); /* in mpd.c */ #ifdef MPD +extern void clear_mpd_stats(struct information *current_info); void *update_mpd(void); extern timed_thread *mpd_timed_thread; #endif /* MPD */ diff --git a/src/mpd.c b/src/mpd.c index 60bec0a3..a1cd39c2 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -33,7 +33,7 @@ timed_thread *mpd_timed_thread = NULL; -static void clear_mpd_stats(struct information *current_info) +void clear_mpd_stats(struct information *current_info) { if (current_info->mpd.artist == NULL) current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE); @@ -90,8 +90,7 @@ void *update_mpd(void) current_info->conn = 0; strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1); - if (timed_thread_test(mpd_timed_thread)) - timed_thread_exit(mpd_timed_thread); + if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread); continue; } @@ -109,8 +108,7 @@ void *update_mpd(void) strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1); timed_thread_unlock(mpd_timed_thread); - if (timed_thread_test(mpd_timed_thread)) - timed_thread_exit(mpd_timed_thread); + if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread); continue; } @@ -161,8 +159,7 @@ void *update_mpd(void) mpd_closeConnection(current_info->conn); current_info->conn = 0; timed_thread_unlock(mpd_timed_thread); - if (timed_thread_test(mpd_timed_thread)) - timed_thread_exit(mpd_timed_thread); + if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread); continue; } @@ -226,8 +223,7 @@ void *update_mpd(void) //fprintf(stderr, "%s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); current_info->conn = 0; - if (timed_thread_test(mpd_timed_thread)) - timed_thread_exit(mpd_timed_thread); + if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread); continue; } @@ -236,8 +232,7 @@ void *update_mpd(void) //fprintf(stderr, "%s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); current_info->conn = 0; - if (timed_thread_test(mpd_timed_thread)) - timed_thread_exit(mpd_timed_thread); + if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread); continue; } mpd_freeStatus(status); @@ -245,9 +240,8 @@ void *update_mpd(void) mpd_closeConnection(current_info->conn); current_info->conn = 0; } - if (timed_thread_test(mpd_timed_thread)) - timed_thread_exit(mpd_timed_thread); - continue; + if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread); + continue; } return 0; }