1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 04:06:03 +00:00

some small fixes for mpd stuff

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@935 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2007-08-31 02:05:02 +00:00
parent 2fcd64d59e
commit 12baf6c0b4
5 changed files with 34 additions and 30 deletions

View File

@ -4,7 +4,7 @@ dnl major, minor and micro version macros.
m4_define([conky_version_major], [1]) m4_define([conky_version_major], [1])
m4_define([conky_version_minor], [4]) m4_define([conky_version_minor], [4])
m4_define([conky_version_micro], [7]) 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_revision],[r@REVISION@])
m4_define([conky_version], m4_define([conky_version],
[conky_version_major().conky_version_minor().conky_version_micro()ifelse( [conky_version_major().conky_version_minor().conky_version_micro()ifelse(

View File

@ -233,7 +233,12 @@ void update_stuff()
#ifdef MPD #ifdef MPD
if (NEED(INFO_MPD)) { if (NEED(INFO_MPD)) {
if (!mpd_timed_thread) { if (!mpd_timed_thread) {
clear_mpd_stats(&info);
mpd_timed_thread = timed_thread_create((void*)update_mpd, (void*) NULL, update_interval * 1000000); 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 #endif

View File

@ -3140,14 +3140,16 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
OBJ(mpd_artist, INFO_MPD) END OBJ(mpd_artist, INFO_MPD) END
OBJ(mpd_title, INFO_MPD) OBJ(mpd_title, INFO_MPD)
{ {
if (arg) if (arg) {
{
sscanf (arg, "%d", &info.mpd.max_title_len); sscanf (arg, "%d", &info.mpd.max_title_len);
if (info.mpd.max_title_len > 0) if (info.mpd.max_title_len > 0) {
info.mpd.max_title_len++; info.mpd.max_title_len++;
else } else {
CRIT_ERR ("mpd_title: invalid length argument"); CRIT_ERR ("mpd_title: invalid length argument");
} }
} else {
info.mpd.max_title_len = 0;
}
} }
END OBJ(mpd_random, INFO_MPD) END OBJ(mpd_random, INFO_MPD)
END OBJ(mpd_repeat, INFO_MPD) END OBJ(mpd_repeat, INFO_MPD)
@ -3192,14 +3194,16 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
OBJ(audacious_status, INFO_AUDACIOUS) END OBJ(audacious_status, INFO_AUDACIOUS) END
OBJ(audacious_title, INFO_AUDACIOUS) OBJ(audacious_title, INFO_AUDACIOUS)
{ {
if (arg) if (arg) {
{
sscanf (arg, "%d", &info.audacious.max_title_len); sscanf (arg, "%d", &info.audacious.max_title_len);
if (info.audacious.max_title_len > 0) if (info.audacious.max_title_len > 0) {
info.audacious.max_title_len++; info.audacious.max_title_len++;
else } else {
CRIT_ERR ("audacious_title: invalid length argument"); CRIT_ERR ("audacious_title: invalid length argument");
} }
} else {
info.audacious.max_title_len++;
}
} }
END END
OBJ(audacious_length, INFO_AUDACIOUS) END OBJ(audacious_length, INFO_AUDACIOUS) END
@ -4967,7 +4971,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
255.0f)); 255.0f));
} }
OBJ(mpd_smart) { 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); snprintf(p, p_max_size, "%s", cur->mpd.file);
} else { } else {
snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title); snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title);

View File

@ -619,6 +619,7 @@ char *get_apm_battery_time(void);
/* in mpd.c */ /* in mpd.c */
#ifdef MPD #ifdef MPD
extern void clear_mpd_stats(struct information *current_info);
void *update_mpd(void); void *update_mpd(void);
extern timed_thread *mpd_timed_thread; extern timed_thread *mpd_timed_thread;
#endif /* MPD */ #endif /* MPD */

View File

@ -33,7 +33,7 @@
timed_thread *mpd_timed_thread = NULL; 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) if (current_info->mpd.artist == NULL)
current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE); current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE);
@ -90,8 +90,7 @@ void *update_mpd(void)
current_info->conn = 0; current_info->conn = 0;
strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1); strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
if (timed_thread_test(mpd_timed_thread)) if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
timed_thread_exit(mpd_timed_thread);
continue; continue;
} }
@ -109,8 +108,7 @@ void *update_mpd(void)
strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1); strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
timed_thread_unlock(mpd_timed_thread); timed_thread_unlock(mpd_timed_thread);
if (timed_thread_test(mpd_timed_thread)) if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
timed_thread_exit(mpd_timed_thread);
continue; continue;
} }
@ -161,8 +159,7 @@ void *update_mpd(void)
mpd_closeConnection(current_info->conn); mpd_closeConnection(current_info->conn);
current_info->conn = 0; current_info->conn = 0;
timed_thread_unlock(mpd_timed_thread); timed_thread_unlock(mpd_timed_thread);
if (timed_thread_test(mpd_timed_thread)) if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
timed_thread_exit(mpd_timed_thread);
continue; continue;
} }
@ -226,8 +223,7 @@ void *update_mpd(void)
//fprintf(stderr, "%s\n", current_info->conn->errorStr); //fprintf(stderr, "%s\n", current_info->conn->errorStr);
mpd_closeConnection(current_info->conn); mpd_closeConnection(current_info->conn);
current_info->conn = 0; current_info->conn = 0;
if (timed_thread_test(mpd_timed_thread)) if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
timed_thread_exit(mpd_timed_thread);
continue; continue;
} }
@ -236,8 +232,7 @@ void *update_mpd(void)
//fprintf(stderr, "%s\n", current_info->conn->errorStr); //fprintf(stderr, "%s\n", current_info->conn->errorStr);
mpd_closeConnection(current_info->conn); mpd_closeConnection(current_info->conn);
current_info->conn = 0; current_info->conn = 0;
if (timed_thread_test(mpd_timed_thread)) if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
timed_thread_exit(mpd_timed_thread);
continue; continue;
} }
mpd_freeStatus(status); mpd_freeStatus(status);
@ -245,8 +240,7 @@ void *update_mpd(void)
mpd_closeConnection(current_info->conn); mpd_closeConnection(current_info->conn);
current_info->conn = 0; current_info->conn = 0;
} }
if (timed_thread_test(mpd_timed_thread)) if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
timed_thread_exit(mpd_timed_thread);
continue; continue;
} }
return 0; return 0;